i like to compare if the Open/Close is in the same direction for two different instruments and calculate a value for the %-correlation over a given period.
I am using a for() loop to get the desired correlation value and divide that by the period to get the percantage of the correlation to in my case "SPY". The problem is, the market analyzer seems to dislike the for() loop (only works while connected to intraday data) and i could imagin there is a better way of doing this...
for(i=1;i<=period;i++) { if( (Close[i] > Open[i] && Closes[1][i] > Opens[1][i]) || (Close[i] < Open[i] && Closes[1][i] < Opens[1][i]) ) // Correlation +1 count++; } double percentVal = 100 * count / period; Plot0.Set(percentVal);
Comment