I'm still a bit new to MQL4 especially after the build 600 changes
Anyway, I'm not sure if my coding is wrong, if this is a bug, or if I don't understand something... but anyway:
double calc[];
for (int loop = 200; loop >= 0; loop--) {
calc[loop] = iRSI(NULL, timeframe, period, price, loop);
}
Ends up with the calc[] array simply full of zeroes.
...You have to give a size to your dynamic array before using it.
double calc[]; ArrayResize(calc,201); // Your are using index 200 to 0, so you need 201 elements for(int loop=200; loop>=0; loop--) { calc[loop]=iRSI(NULL,timeframe,period,price,loop); }
Yes, the ArrayResize does fix it too, but I am still left with the tricky problem of this:
double priceline[];
ArrayResize(priceline,201);
double calc[];
ArrayResize(calc,201);
for (int loop = 200; loop >= 0; loop--) {
calc[loop] = iRSI(NULL, timeframe, period, price, loop);
}
for (loop = 199; loop >= 0; loop--) {
priceline[loop] = iMAOnArray(calc, timeframe, priceline, 0, pricetype, loop);
}
I did some debugging on the output, and while the calc[] array has values in each index of the array from 0 to 200, the priceline[] array has zero in each index from 14 upwards. All indexes from 0-13 have a value.
What's going on?
just for information purposes you can use
for (loop = ArraySize(calc).....)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm still a bit new to MQL4 especially after the build 600 changes
Anyway, I'm not sure if my coding is wrong, if this is a bug, or if I don't understand something... but anyway:
double calc[];
for (int loop = 200; loop >= 0; loop--) {
calc[loop] = iRSI(NULL, timeframe, period, price, loop);
}
Ends up with the calc[] array simply full of zeroes.
However if I define
double calc[200];
Then it works just fine.
Mind you, this is inside an EA and not an indicator. As I am trying to port the code from an indicator directly into an EA, I just don't understand why it's behaving this way, if it's supposed to, or if I should know better.
I also have a similar routine with iMAOnArray which does something similar, except that even when it is defined only the first 13 in the array get a value and everything else is zero.
To me it's making no sense at all.