indiTraders - Forum for the Active Indian Trader  

Go Back   indiTraders - Forum for the Active Indian Trader > Technical > Indicators & Systems

Indicators & Systems Compendium of Code

Reply
 
Bookmark and Share LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-05-2010, 09:12 PM
anirudhsnewworl's Avatar
anirudhsnewworl anirudhsnewworl is offline
indiTraders VIP
 
Join Date: Jul 2009
Posts: 458
Thanks: 907
Thanked 1,080 Times in 367 Posts
anirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to all
Default Quantitative Trading

let's discuss quantative aspects of trading
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 10 Users Say Thank You to anirudhsnewworl For This Useful Post:
  #2 (permalink)  
Old 09-05-2010, 09:13 PM
anirudhsnewworl's Avatar
anirudhsnewworl anirudhsnewworl is offline
indiTraders VIP
 
Join Date: Jul 2009
Posts: 458
Thanks: 907
Thanked 1,080 Times in 367 Posts
anirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to all
Default does averaging-in work?

Ron Schoenberg and Al Corwin recently did some interesting research on the trading technique of "averaging-in". For e.g.: Let's say you have $4 to invest. If a future's price recently drops to $2, though you expect it to eventually revert to $3. Should you

A) buy 1 contract at $2, and wait for the price to possibly drop to $1 and then buy 2 more contracts (i.e. averaging-in); or
B) buy 2 contracts at $2 each; or
C) wait to possibly buy 4 contracts at $1 each?

Let's assume that the probability of the price dropping to $1 once you have reached $2 is p. It is easy to see that the average profits of the 3 options are the following:
A) p*(1*$1+2*$2) + (1-p)*(1*$1)=1+4p;
B) 2; and
C) p4*$2=8p.

Profit A is lower than C when p > 1/4, and profit A is lower than profit C when p > 1/4. Hence, whatever p is, either option B or C is more profitable than averaging in, and thus averaging-in can never be optimal.

From a backtest point of view, the Schoenberg-Corwin argument is impeccable, since we know what p is for the historical period. You might argue, however, that financial markets is not quite stationary, and in my example, if the historical value of p was less than 1/4, it is quite possible that the future value can be more than 1/4. This is why I never make too much effort to optimize parameters in general, and I can sympathize with traders who insist on averaging-in even in the face of this solid piece of research!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 7 Users Say Thank You to anirudhsnewworl For This Useful Post:
  #3 (permalink)  
Old 09-05-2010, 09:26 PM
anirudhsnewworl's Avatar
anirudhsnewworl anirudhsnewworl is offline
indiTraders VIP
 
Join Date: Jul 2009
Posts: 458
Thanks: 907
Thanked 1,080 Times in 367 Posts
anirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to all
Default statistical arbitrage

Statistical arbitrage pairs is a strategy that bets divergences in stock pairs sharing common factor risk will revert to a stationary mean, allowing us to fade these divergences and make money.

Historically StatArb evolved out of the simpler pairs trade strategy, in which stocks are put into pairs by fundamental or market-based similarities. When one stock in a pair outperforms the other, the poorer performing stock is bought long with the expectation that it will climb towards its outperforming partner, the other is sold short. This hedges risk from whole-market movements.

StatArb considers not pairs of stocks but a portfolio of a hundred or more stocks (some long, some short) that are carefully matched by sector and region to eliminate exposure to beta and other risk factors. Portfolio construction is automated and consists of two phases: in the first or 'scoring' phase each stock in the market is assigned a numeric score or rank that reflects its desirability; high scores indicate stocks that should be held long and low scores indicate stocks that are candidates for shorting. The details of the scoring formula vary and are highly proprietary, but generally (as in pairs trading) they involve a short term mean reversion principle so that, e.g., stocks that have done unusually well in the past week receive low scores and stocks that have underperformed receive high scores. In the second or 'risk reduction' phase the stocks are combined into a portfolio in carefully matched proportions so as to eliminate (or at least greatly reduce) market and factor risk. :exclaim:
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 9 Users Say Thank You to anirudhsnewworl For This Useful Post:
  #4 (permalink)  
Old 09-05-2010, 09:32 PM
anirudhsnewworl's Avatar
anirudhsnewworl anirudhsnewworl is offline
indiTraders VIP
 
Join Date: Jul 2009
Posts: 458
Thanks: 907
Thanked 1,080 Times in 367 Posts
anirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to all
Default how to select tradeable pairs for statistical arbitrage(continuation of above)

there are many methods to pair basket of stocks for pair trading
But which approach is best? To find out I take a universe of stocks with similar fundamental characteristics, define a set of basic trading rules that involve selling one stock and buying another when the ratio exceeds a threshold, and exiting the trade when the ratio touches a rolling mean. This generates some approximate measures of profitability (% wins, cumulative profitability).

read below article for selecting best method(which is ADF)

http://www.paulfarrington.com/resear...le%20pairs.htm

now comes the most important part..to develop a trading system for statistical trading pair arbitrage
there are many softwares which can be used namely excel,matlab,mathematica,R
article below will discuss abot developing using "R"

@JJ sir,adheer,oxymoron and others any one using pair arbitrage for trading? need some help if someone is using R for the same..plz help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 6 Users Say Thank You to anirudhsnewworl For This Useful Post:
  #5 (permalink)  
Old 09-05-2010, 09:39 PM
anirudhsnewworl's Avatar
anirudhsnewworl anirudhsnewworl is offline
indiTraders VIP
 
Join Date: Jul 2009
Posts: 458
Thanks: 907
Thanked 1,080 Times in 367 Posts
anirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to all
Default Trading with Mean Reversion

Throughout financial history, there has been three effective ways to make money. They are, not in particular order:

1. The carry trade. This is where one borrows and leverages in a market and buys in another. An arbitrage is a carry trade, for example. This carry trade works very well at the beginning of a theme - that is, until everyone and his neighbor has adopted it. The yen carry trade that blew up in 1998 was one great example of the end of a carry trade.

2. Momentum "investing." Everyone should be familar with this trade, as I am sure virtually all our readers have gone through the 1990s technology bubble.

3. Mean reversion trade. This is where one buys an undervalued stock or commodity and wait for it to return to its true value. Warren Buffett is known for adopting this strategy to perfection (although he has done other trades at various points in his career).

Even though the world's financial markets have gotten more efficient as time goes on, mean reversion trades have still invariably "popped up" every now and then. They come into being when three forces come together:

1. Group think and a herd mentality: The universal belief that an asset class has just got to go up or down forever - resulting in a huge overvaluation (relative to historical average) of the current asset class in favor. The most recent example has been the bottoming of the U.S. Dollar in January this year. Not surprisingly, the U.S. dollar bottomed at about the same time a front-page bearish article on the U.S. dollar appeared on Newsweek.

2. The ability for retail investors to participate in such a trade - and the widespread publicity this trade has "enjoyed" from the mass media.

Traders who utilize the Market Profile framework should be quite familiar with the mean reversion trade. When we test edges of the value range and cannot facilitate trade at higher or lower levels, a move back toward the point of control is a high probability trade.
http://www.youtube.com/watch?v=1IFXMS9xn_E

Last edited by anirudhsnewworl; 09-05-2010 at 09:50 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 5 Users Say Thank You to anirudhsnewworl For This Useful Post:
  #6 (permalink)  
Old 09-05-2010, 09:46 PM
anirudhsnewworl's Avatar
anirudhsnewworl anirudhsnewworl is offline
indiTraders VIP
 
Join Date: Jul 2009
Posts: 458
Thanks: 907
Thanked 1,080 Times in 367 Posts
anirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to all
mad Identifying Mean Reversion Opportunities

Finding good mean reversion opportunities is straightforward: you simply need to define a range across some time span, and take contrarian positions when the underlying moves beyond that range. Here are some rules for a very basic (but effective) mean reversion strategy:

# Note the intraday high and low of the prior week. We use intraday prices rather than closing prices to get a more accurate picture of the prior week's trading range.

# If the underlying closes above (below) the prior week's range, sell (buy) the underlying at the close.

# Exit the trade 7 days later or when a new signal is generated, whichever comes first.

Now, this is obviously just one strategy among many you could use. We're using a weekly range as our basis, but other timeframes are worth exploring as well, including even intraday ranges. Nor should you restrict your research to price levels alone - viable strategies can be developed using moving averages and Bollinger Bands, for example. Our exit criterion is also somewhat arbitrary; performance is robust across shorter and longer holding periods. Notice that we allow for new signals to reverse our exposure; however, the average holding time per trade was still 6.8 days, indicating that most trades were exited based on our time condition, rather than due to an offsetting signal

this is not a strategy for traders who can't bear to lose: trades were profitable only about 53% of the time, though the winners were about 25% larger than the losers.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 4 Users Say Thank You to anirudhsnewworl For This Useful Post:
  #7 (permalink)  
Old 09-05-2010, 09:48 PM
anirudhsnewworl's Avatar
anirudhsnewworl anirudhsnewworl is offline
indiTraders VIP
 
Join Date: Jul 2009
Posts: 458
Thanks: 907
Thanked 1,080 Times in 367 Posts
anirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to all
eeky using options for mean reversion

Using Options to Trade Mean Reversion | TradingMarkets.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 7 Users Say Thank You to anirudhsnewworl For This Useful Post:
  #8 (permalink)  
Old 09-05-2010, 09:49 PM
anirudhsnewworl's Avatar
anirudhsnewworl anirudhsnewworl is offline
indiTraders VIP
 
Join Date: Jul 2009
Posts: 458
Thanks: 907
Thanked 1,080 Times in 367 Posts
anirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to all
Cool black swan vs mean reversion

Anatomy of Technical Trading: Black Swan Or Mean Reversion - Bo Peng -- Seeking Alpha
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 5 Users Say Thank You to anirudhsnewworl For This Useful Post:
  #9 (permalink)  
Old 09-05-2010, 10:01 PM
Adheer's Avatar
Adheer Adheer is offline
Regulars
 
Join Date: Apr 2009
Posts: 528
Thanks: 265
Thanked 2,324 Times in 469 Posts
Adheer is a splendid one to beholdAdheer is a splendid one to beholdAdheer is a splendid one to beholdAdheer is a splendid one to beholdAdheer is a splendid one to beholdAdheer is a splendid one to beholdAdheer is a splendid one to beholdAdheer is a splendid one to beholdAdheer is a splendid one to beholdAdheer is a splendid one to beholdAdheer is a splendid one to beholdAdheer is a splendid one to behold
Default

Nice work. Keep going.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to Adheer For This Useful Post:
  #10 (permalink)  
Old 09-05-2010, 10:14 PM
anirudhsnewworl's Avatar
anirudhsnewworl anirudhsnewworl is offline
indiTraders VIP
 
Join Date: Jul 2009
Posts: 458
Thanks: 907
Thanked 1,080 Times in 367 Posts
anirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to allanirudhsnewworl is a name known to all
Default

Originally Posted by Adheer View Post
Nice work. Keep going.

sir apko hi abhi mail karne ki soch raha tha main
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to anirudhsnewworl For This Useful Post:
Reply

indiTraders - Forum for the Active Indian Trader > Technical > Indicators & Systems


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 05:59 AM.


vBulletin Copyright by vBulletin

Content Relevant URLs by vBSEO 3.3.2