and the code doesnt exit the loop
any help ?
It exits loops somewhere but OnTick is being called with every incoming tick
-
Nothing is changing inside your loop. Stop trying. Exit and wait for a new tick.
-
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
MT4: New candle - MQL4 programming forum #3 (2014)
MT5: Accessing variables - MQL4 programming forum #3 (2022)I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
Running EA once at the start of each bar - MQL4 programming forum (2011)
It seems that you have a X/Y problem issue. It is probable that you are in fact trying to detect a new bar event and going about it the wrong way by looking for a change in bar count.
A more correct way of detecting a new bar event is as follows:
Detecting the start of a new bar or candle
Fernando Carreiro, 2022.04.24 00:38
Detecting the start of a new bar or candle, in the OnTick() event handler of an expert advisor.
It seems that you have a X/Y problem issue. It is probable that you are in fact trying to detect a new bar event and going about it the wrong way by looking for a change in bar count.
A more correct way of detecting a new bar event is as follows:
Thanks Fernando, Always to the rescue
i will look into your code for sure

- 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 trying to exit a loop after number of bars appears
the code is like that
however i am getting a warning
declaration of 'barnum1' hides local variable
and the code doesnt exit the loop
any help ?