This article explores how to create a correlation matrix table between Bank Stocks(includes bank nifty in our case) using amibroker.
The correlation between any two stocks (or sets of variables) summarizes a relationship, whether or not there is any real-world connection between the two stocks. The correlation coefficient will always be between -1 and +1. These two extremes are considered perfect correlations. A negative coefficient means that the two stocks,, will move in opposite directions (if one stock increases, the other will decrease); a positive coefficient will mean that the two will move in the same direction (as one increases, the other will increase). And if Correlation is zero(perfectly uncorrelated) or almost zero then both the stock will behave independently
About Correlation Table[wp_ad_camp_5]
Correlation table is a two-dimensional matrix that shows correlation coefficient between pairs of securities. The cells in the table are color-coded to highlight significantly positive and negative relationships.
Here i had taken randomly some Bank stocks from the NSE Pack and computed the correlation for the pairs using amibroker
Steps to Create Amibroker Correlation Matrix
1)Put the Bank Stocks(or your set of stocks) in Watchlist 0
2)Copy the Below AFL code and save as correlation.afl and save under the path C:program filesamibrokerformulascustomcorrelation.afl
3)Now open New Analysis (use AA-Automatic Analysis if you are using less than 5.4 version)
4)Select correlation AFL file
5)Now Press the Explore Buttom
6)Correlation table is ready
You can also vary the correlation period and can test for different set of stock pairs. This could be useful for pair trading strategy or for diversification of your portfolio by investing in less correlated pairs.so that an investor can reduce portfolio risk simply by holding instruments which are not perfectly correlated. In other words, investors can reduce their exposure to individual asset risk by holding a diversified portfolio of assets.
Creating a Correlation Table – Amibroker Library