It works fine as long a i keep the number below i+4 in the line below - if i change it to i+5 i get the error "array out of range xxxx.mq4 (253,53)
Help people to help you by highlighting the line of code that is causing the problem.
Help people to help you by highlighting the line of code that is causing the problem.
Ok done thx.
Ok done thx.
I found out what the problem was, i'm trying to give it a higher number than i have candles to the right, the line cannot show in future so to speak.
At least it has to be done in another way.
And i don't know how to do that
Add this line to the top:
#property strict
Then you need to make sure that i-5 will never be below 0 (otherwise you get that error) and that
i+5 will never be larger than Bars-1 like so:
if(i-5>=0 && i+5<Bars) { string strObjectNameLow = "Example line"+dir+i; ObjectCreate(strObjectNameLow, OBJ_TREND, 0, Time[i-5], value, Time[i+5], value); ObjectSet(strObjectNameLow, OBJPROP_RAY, false); }
You need to complete it yourself for the other places where i-10 or i+10 is used.
By the way the indicator code is outdated, it should be migrated to the actual MT4 release.
Add this line to the top:
Then you need to make sure that i-5 will never be below 0 (otherwise you get that error) and that
i+5 will never be larger than Bars-1 like so:
You need to complete it yourself for the other places where i-10 or i+10 is used.
By the way the indicator code is outdated, it should be migrated to the actual MT4 release.
#property strictIt's already in the code, just forgot to copy/paste that in as well. My mistake.
Thank you for the code example.
I'm not very skilled coder and do not code very often so i wasn't aware of that. I have to look into the actual MT4 release
Thx.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I have an indicator that show me 3 bar fractals. I'm drawing lines on OHLC of a candle and that's where it gives me some problems.
It works fine as long a i keep the number below i+4 in the line below - if i change it to i+5 i get the error "array out of range xxxx.mq4 (253,53)
Here is the code i'm working on
I know i have to use ArrayResize, but i cannot find out to put it in the code correctly so it removes the array out of range error.
This is how it looks like when the number is i+4
And when the number is changed to i+5 it looks like this