This is a trading object shared by a member. You can use this object as well as hundreds of others with QuantShare - Trading Software.
Click on the Like button or on one of the share buttons to share this object and spread the word about QuantShare.
QuantShare is an advanced trading software for stock, forex, futures, ETF and options markets. It is the best and the most complete EOD trading software software and it is FREE (beta version).
This composite index calculates for each stock, its close price correlation with the close price of an index. It then averages the results and creates the Average Correlation Index, whose symbol name is "Correl_10bars".
For each trading bar and for each stock (only stocks whose close prices are above two are selected), the correlation between this stock and the index is calculated for the preceding 10 bars. The index involved in the correlation is the "^GSPC" or the S&P 500.
You can update both, the correlation period and the index symbol name. You can also modify the list of symbols used by this composite.
In order to change the correlation period, you will have to update the composite item and change its formula. The first line "period = 10;" defines the period.
In order to change the index, which is currently set to S&P 500, replace "^GSPC" and type in the index symbol name you want to use. As an example, if you want to calculate the average correlation between stocks listed on the Bombay Stock Exchange and this exchange main index, type in "^BSESN" as the index symbol name (Use BSE Sensex to download historical end-of-day for the Bombay Stock Exchange Sensitive Index). For the National Stock Exchange, you should use "^S&P_CNX_Nifty" instead of "^GSPC" (NSE Nifty - S&P CNX Nifty).
A high value for the Average Correlation Index may indicate that many stocks are correlated with the S&P 500. And a low value for this composite indicates that there is a low correlation between individual stocks and the S&P 500 index.
From 2001 to 2009, a simple strategy that buys the S&P 500 when its 10-bar rate-of-return is negative and the Average Correlation Index is higher than 0.5 (50%) and exits the position after 5 bars, generated 35 trades and produced an average gain of 0.356% per bar.
A simple strategy that shorts the S&P 500 when its 10-bar rate-of-return is positive and the Average Correlation Index is higher than 0.5 and exits the position after 5 bars, generated 23 trades and produced an average gain of 0.245% per bar.