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.
New candle - MQL4 programming forum #3 2014.04.04
I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
anyway, if you need to run some functions once a candle, you can use Volume() function to check the volume of the latest candle.
I really wouldn't use Volume[0] to test for new bars. There have been repeated real-life tests saying that it's not fully reliable.
For example: https://www.mql5.com/en/forum/125906#comment_3272369 and the topics it links to. While those discussions are over 10 years old, I wouldn't assume that it's become any more reliable during that time.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I currently coded an EA all in the OnTick function. Similar to this template:
I noticed this works how I want and expect during backtesting.
When forward testing live though, I am seeing it do things like spam multiple orders within seconds, even though it is on the Daily chart.
After researching this phenomenon, I found some information about how this might be related to ticks vs candles. I was wondering if someone could tell me more about this idea and point me in the right direction and provide some guidance on what should be done OnTick vs. OnNewCandle? I already noticed that probably OrderSend() should be done only on new candles or else it will spam orders like I saw. Should things like signals also be checked only on new candles?
Also, during backtesting I usually pick the "on Open Prices" option because the "on Ticks" option takes much longer. Is this the reason why I didn't notice any issues during backtesting? When using this testing mode, does it just automatically take OnTick() and only run it for new candles?
Please advise. Thank you!