for(i=iBars(NULL,TimeFrame)-1-prev_calculated; i>0; i--) { if(TimeFrame==Period()) { Up = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, Range, i)); Dn = iLow (NULL, 0, iLowest (NULL, 0, MODE_LOW, Range, i)); } else if(TimeFrame>Period()) { hightfshift=iBarShift(NULL,TimeFrame,Time[i],true); if(hightfshift==-1) continue; Up = iHigh(NULL, TimeFrame, iHighest(NULL, TimeFrame, MODE_HIGH, Range, hightfshift)); Dn = iLow (NULL, TimeFrame, iLowest (NULL, TimeFrame, MODE_LOW, Range, hightfshift)); } else if(TimeFrame<Period()) { smalltfshift=iBarShift(NULL,TimeFrame,Time[i],true); if(smalltfshift==-1) continue; timeshift=iTime(NULL,TimeFrame,smalltfshift); xshift=iBarShift(NULL,TimeFrame,timeshift,true); Up = iHigh(NULL, TimeFrame, iHighest(NULL, TimeFrame, MODE_HIGH, Range, xshift)); Dn = iLow (NULL, TimeFrame, iLowest (NULL, TimeFrame, MODE_LOW, Range, xshift)); } Resistance[i]=Up; Support[i]=Dn; }
i changed
for(i=iBars(NULL,TimeFrame)-1-prev_calculated; i>=0; i--)
to
for(i=iBars(NULL,TimeFrame)-1-prev_calculated; i>0; i--)
its important to realize you get the out of range error when you try to read a value that does not exists / lies outside of the range of the array.
i can not find in your code, the value of
-prev_calculated;
i suspect it to be the source of the error.
i changed
to
its important to realize you get the out of range error when you try to read a value that does not exists / lies outside of the range of the array.
i can not find in your code, the value of
i suspect it to be the source of the error.
Yes, still not work if only changed "i >= 0" to "i > 0"
I think at this part
else if(TimeFrame<Period()) { smalltfshift=iBarShift(NULL,TimeFrame,Time[i],true); if(smalltfshift==-1) continue; timeshift=iTime(NULL,TimeFrame,smalltfshift); xshift=iBarShift(NULL,TimeFrame,timeshift,true); Up = iHigh(NULL, TimeFrame, iHighest(NULL, TimeFrame, MODE_HIGH, Range, xshift)); Dn = iLow (NULL, TimeFrame, iLowest (NULL, TimeFrame, MODE_LOW, Range, xshift)); }
need to use Array, but I dont know how :(
it is only logical to write
i>0;
Because then it stops at 0 when i==0 where in the other case,
i>=0;
It will make one more step when i==0, this means the last integer would be -1 and all conventional array's will produce an out of range error when you try to read this value.
When it comes to reading bar data -1 does exist so the end conclusion is that if
-prev_calculated
is above 0, the array will be out of range.
so you try
for(i=iBars(NULL,TimeFrame);i>0; i--) { if(TimeFrame==Period()) { Up = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, Range, i)); Dn = iLow (NULL, 0, iLowest (NULL, 0, MODE_LOW, Range, i)); } else if(TimeFrame>Period()) { hightfshift=iBarShift(NULL,TimeFrame,Time[i],true); if(hightfshift==-1) continue; Up = iHigh(NULL, TimeFrame, iHighest(NULL, TimeFrame, MODE_HIGH, Range, hightfshift)); Dn = iLow (NULL, TimeFrame, iLowest (NULL, TimeFrame, MODE_LOW, Range, hightfshift)); } else if(TimeFrame<Period()) { smalltfshift=iBarShift(NULL,TimeFrame,Time[i],true); if(smalltfshift==-1) continue; timeshift=iTime(NULL,TimeFrame,smalltfshift); xshift=iBarShift(NULL,TimeFrame,timeshift,true); Up = iHigh(NULL, TimeFrame, iHighest(NULL, TimeFrame, MODE_HIGH, Range, xshift)); Dn = iLow (NULL, TimeFrame, iLowest (NULL, TimeFrame, MODE_LOW, Range, xshift)); } Resistance[i]=Up; Support[i]=Dn; }
Yes, still not work if only changed "i >= 0" to "i > 0"
I think at this part
need to use Array, but I dont know how :(
if the problem lies elsewhere you can always force the integers positive, if they turn out to be negative for whatever reason, but realize this can produce false results so you can use it to identify the problem.
else if(TimeFrame<Period()) { smalltfshift=iBarShift(NULL,TimeFrame,Time[i],true); if(smalltfshift==-1) continue; timeshift=iTime(NULL,TimeFrame,smalltfshift); xshift=iBarShift(NULL,TimeFrame,timeshift,true); // reset if <0 if(xshift<0){xshift=0;} if(smalltfshift<0){smalltfshift=0;} if(timeshift<0){timeshift=0;} Up = iHigh(NULL, TimeFrame, iHighest(NULL, TimeFrame, MODE_HIGH, Range, xshift)); Dn = iLow (NULL, TimeFrame, iLowest (NULL, TimeFrame, MODE_LOW, Range, xshift)); }
Also, look at the array out of range error it will give you the exact line number and position where it dropped out.
Hi Marco, thanks again for assist me , but still not work.
Here my indicator (not finish yet), maybe you can help to correct it or tell me where is the mistakes
Error Array out of range happen when timeframe (from button) "clicked" < Period()
- 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 am try to creating an Indicator and my problem is Array Out of Range.
I am already search anywhere to fix this problem but still not found it.
here my little script :
the problem is at "TimeFrame < Period()"
so, if someone can help, please share a little script to me
Thanks before
Rudi