I wrote my own indicator and am having the weirdest problem. The indicator will display perfectly when I drag it onto the chart, but when I use it within the EA I get completely different results. I can't figure this out.
-There's only a single variable, set for 5, on the indicator in both the chart AND code.
-None of these are ASSIGNED in the rest of the EA or Indicator, so what's listed below in code IS the values.
Code:
// Get direction from indicator
int direction=0;
double bwSig[10];
double bwTop[10];
double bwBot[10];
ArrayInitialize(bwSig,0);ArrayInitialize(bwTop,0);ArrayInitialize(bwBot,0);
for (int a=0;a<=9;a++) {
bwSig[a]=iCustom(NULL,Period(),"barWorth-v2",5,0,a);
bwTop[a]=iCustom(NULL,Period(),"barWorth-v2",5,1,a);
bwBot[a]=iCustom(NULL,Period(),"barWorth-v2",5,2,a);
}
if (bwSig[1]>bwTop[1] && bwSig[2]<bwTop[2]) {direction=1;}
if (bwSig[1]<bwBot[1] && bwSig[2]>bwBot[2]) {direction=-1;}
Cmt=Cmt+"Direction: " + direction + "\n";
Cmt=Cmt+"BW sig top bot (1 offset): " + bwSig[1] + " " + bwTop[1] + " " + bwBot[1] + "\n";