count = prev_calculated - 1;
mean : i = count = rates_total - 2
>> rates_total - i - 3 = rates_total - (rates_total - 2) - 3 = -1
i don't understand why you calculator all bar every new bar
for(i = count; i < rates_total - 1; i ++)
mean : i = count = rates_total - 2
>> rates_total - i - 3 = rates_total - (rates_total - 2) - 3 = -1
i don't understand why you calculator all bar every new bar
Hey! Thanks Anyways, i did it!, just i change the scale !
but why u said "i don't understand why you calculator all bar every new bar", because prev_calc only once is 0.
Hello Everyone!,
I can't make this work!, debugger show me "Array out of range", surely must be the main loop but where?
Thanks in Advanced!
Reggards!
You have a loop
for(i = count; i < rates_total - 1; i ++)
At some point then i=rates_total-2.
Then you have in your if statement
high[rates_total - i - 3]
Think about the index to the array.
rates_total-i-3 = rates_total-(rates_total-2)-3 = 2-3 = -1
Ohh Thanks all for the help!!
Very thankful
it is showing Out of range because, the program is requesting for a candle that is not there, you can
//--- Print the total number (rates_total) of bars in the chart //--- and print the value of "i" inside the loop as the program is running
Then the prev_calculated is only equal to zero at the beginning of the program and when a new bar is added, but when new ticks are coming it is equal to zero, hence if you are in the H1 TF, per ticks count would be equal to zero, then when a new bar comes,
// The value of count would still be zero count = prev_calculated -1 // prev_calculated would be 1 after the first run and zero per tick
this is a common misconception. Read this page https://www.mql5.com/en/forum/151666/page3#comment_3772589
read the above the comments they have showed what is wrong with the logic in your loop
// Then this would provide a different result than what you are thinking (high[i] >= high[i - 1] && high[i - 2] && high[i - 3]) // it only compares the first two highs , the 3rd and 4th highs are always true in as much as the high is having a value. // from your code, I am guessing you want the buffer to hold the candles high only if it higher than that of the previous 4 candles to its side // then ensure "i" is greater than the amount of candles that you are comparing or the program would give "Array out of range error

- 2014.06.17
- www.mql5.com
it is showing Out of range because, the program is requesting for a candle that is not there, you can
Then the prev_calculated is only equal to zero at the beginning of the program and when a new bar is added, but when new ticks are coming it is equal to zero, hence if you are in the H1 TF, per ticks count would be equal to zero, then when a new bar comes,
this is a common misconception. Read this page https://www.mql5.com/en/forum/151666/page3#comment_3772589
read the above the comments they have showed what is wrong with the logic in your loop
yep is working!!, thanks all :)

- 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 Everyone!,
I can't make this work!, debugger show me "Array out of range", surely must be the main loop but where?
Thanks in Advanced!
Reggards!