Do your lookbacks correctly #9 — #14 & #19. (2016)
Thanks, could you show me how exactly do you amend the code?
Peter.
When you have an index i-1 and at some point i=0,
ok thanks so should I put a condition to calculate only if i>1?
Oh no, I haven't looked right, in your code says:
if(prev_calculated==0){ ... limit=1; // So you have already done that, I guess... because i starts at 1 according to that predefinition. } else limit=prev_calculated-1 // That is, prev_calculated is getting big during the first OnCalculate() event (or tick let's say... // so i will not be -1 here)
Or have you changed the code, because now it seems right, also in the debugger I don't get out of range, so... I am not sure if it shows what a HA is supposed to but it works.
Do you still get the error?William provided you with 3 links in his post. You need to click on them, and read their contents.
They provide source code samples and explanations. Please read them carefully and adapt them to your code.
Forum on trading, automated trading systems and testing trading strategies
Array out of range Heiken ashi indicator
William Roeder, 2022.09.19 23:17
Do your lookbacks correctly #9 — #14 & #19. (2016)
I have added
i >= 1
on the code below and now cant see the error. The EA brings this error only when I attach it on the chart. The indicator is pulled to the EA through an Icustom function call
for(i=limit;i<rates_total &&i >= 1&& !IsStopped();i++)
- 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 am getting this error on the H ashi indicator:
array out of range in 'heiken_ashi.mq5'
on this line:
double haOpen=(ExtOBuffer[i-1]+ExtCBuffer[i-1])/2;
The whole code is shown below:
How could this error be solved?