- Joined
- 12 June 2017
- Posts
- 1
- Reactions
- 0
Hi,
I really want to know how to implement this. I want to measure correlation between instruments but the correlation range needs to dynamically be determined. I tried to find ways to implement the array as a number by using LastValue ( range ) but this seems to default to 0 and doesn't work. It looks like I need to implement some kind of a loop but don't know how to do it.
Say we have this below
bi = BarIndex();
S = Cross(MA(C, 4), MA(C,8));
c1 = ValueWhen( S, MA(C, 4), 1) > ValueWhen( S, MA(C, 4), 2);
Range = ValueWhen( S, bi, 1) - ValueWhen( S, bi, 2);
c2 = Correlation(C, Foreign("APPL", "C"), Range) > 0.7;
// You can see the correlation between the stocks are determined by the two cross over points which always changes.
Buy = c1 and c2;
Please help me implement this !
Thanks !
I really want to know how to implement this. I want to measure correlation between instruments but the correlation range needs to dynamically be determined. I tried to find ways to implement the array as a number by using LastValue ( range ) but this seems to default to 0 and doesn't work. It looks like I need to implement some kind of a loop but don't know how to do it.
Say we have this below
bi = BarIndex();
S = Cross(MA(C, 4), MA(C,8));
c1 = ValueWhen( S, MA(C, 4), 1) > ValueWhen( S, MA(C, 4), 2);
Range = ValueWhen( S, bi, 1) - ValueWhen( S, bi, 2);
c2 = Correlation(C, Foreign("APPL", "C"), Range) > 0.7;
// You can see the correlation between the stocks are determined by the two cross over points which always changes.
Buy = c1 and c2;
Please help me implement this !
Thanks !