I must be going nuts, because for the life of me this SHOULD work. The differences array is set on the global scope, so it doesn't need to be here. Otherwise...
Here's the output I get:
Dif: 0.0046043 Cnt: 1299 Dif array: 0.0000000
The dif and the cnt both update correctly, but the array is just not holding anything. I've tried to set it as a series, I've tried to initialize it, it's always 0.
Anyone else had this kind of problem?
Code...
Here's the output I get:
Dif: 0.0046043 Cnt: 1299 Dif array: 0.0000000
The dif and the cnt both update correctly, but the array is just not holding anything. I've tried to set it as a series, I've tried to initialize it, it's always 0.
Anyone else had this kind of problem?
Code...
Inserted Code
double BuildDifferenceArray(int MA_period, int MA_type, int TimeFrame) { // Scan each bar, add to the differences array as appropriate. double MA_value, diff; int BarMax = MathMin(iBars(Symbol(), TimeFrame), 1000); array_cnt = 0; for(int BarCnt=1; BarCnt <= BarMax; BarCnt++) { MA_value = iMA(Symbol(),TimeFrame,MA_period,0,MA_type,0,BarCnt); if (iHigh(Symbol(),TimeFrame,BarCnt) > MA_value) { array_cnt++; diff = MathAbs(iHigh(Symbol(),TimeFrame,BarCnt) - MA_value); differences[array_cnt] = diff; Print("Dif: " + diff + " Cnt: " + array_cnt + " Dif array: " + differences[array_cnt]); } if (iLow(Symbol(),TimeFrame,BarCnt) < MA_value) { array_cnt++; diff = MathAbs(MA_value - iLow(Symbol(),TimeFrame,BarCnt)); differences[array_cnt] = diff; Print("Dif: " + diff + " Cnt: " + array_cnt + " Dif array: " + differences[array_cnt]); } } }