Originally Posted By: tradingest
Andrew,

I read the manual but I can not quite understand the value inserted within the correlation ... should indicate the bars so if barperiod = 1 and set 240 I should get the correlation relative to 4 hour I say well?

The way you wrote your code, you are checking for the correlation between the two assets, for the one-minute bars, for the past 240 samples, which would be the last four hours. That is, you gain a sample and lose a sample once a minute.