array out of range error
Level = Levels[j];
after the word "Levels"
How do I fix this?
for(int j=0; j<=ArraySize(Levels); j++)
...It should be "j < ArraySize(Levels)" and not "<=".
Good day to you Fernando,
I get a similar sort of error message, but there is no "ArraySize" anywhere in the code of my indicator.
Message is:
2020.03.27 19:00:00.687 sm3BarFractalBreak v2.0 US30,M30: array out of range in 'sm3BarFractalBreak v2.0.mq4' (202,62)
Any suggestions please?
Thanking you sincerely for replying.
Hercs.
I get a similar sort of error message, but there is no "ArraySize" anywhere in the code of my indicator.
Message is:
2020.03.27 19:00:00.687 sm3BarFractalBreak v2.0 US30,M30: array out of range in 'sm3BarFractalBreak v2.0.mq4' (202,62)
- Don't Hijack other threads for your off-topic post. Next time, make your own, new, thread.
- Indicators don't need ArraySize, they have automatically resized buffers.
- Do you really expect an answer? We can't see your broken code — we can only guess. There are no mind readers here and our crystal balls are cracked.
- You are likely looking past the end of the buffer.
How to do your lookbacks correctly.
An MQL4 function I've created and used before in prior MT4 versions is now yielding an "array out of range error" in my EA in latest version of MT4. I've searched around and can't find an answer. The error is referencing the line:
Level = Levels[j];
after the word "Levels"
How do I fix this?
Thanks
Bill
//-----------------------------------
// RainbowTop() Function
//-----------------------------------
double RainbowTop(int BarsBack)
{
double MA1 = NormalizeDouble(iMA(Symbol(), Period(), 8, 0, MODE_EMA, PRICE_CLOSE, BarsBack), Digits());
double MA2 = NormalizeDouble(iMA(Symbol(), Period(), 13, 0, MODE_EMA, PRICE_CLOSE, BarsBack), Digits());
double MA3 = NormalizeDouble(iMA(Symbol(), Period(), 21, 0, MODE_EMA, PRICE_CLOSE, BarsBack), Digits());
double MA4 = NormalizeDouble(iMA(Symbol(), Period(), 34, 0, MODE_EMA, PRICE_CLOSE, BarsBack), Digits());
double MA5 = NormalizeDouble(iMA(Symbol(), Period(), 55, 0, MODE_EMA, PRICE_CLOSE, BarsBack), Digits());
double Levels[5];
Levels[0] = MA1;
Levels[1] = MA2;
Levels[2] = MA3;
Levels[3] = MA4;
Levels[4] = MA5;
double TopLevel = 0;
double Level = 0;
for(int j=0; j<=ArraySize(Levels); j++)
{
Level = Levels[j];
if (Level > TopLevel)
{
TopLevel = Level;
}
}
return(TopLevel);
}