- Move lastbar globally and set it to zero in init.
Simplified bool NewBar(){ static datetime lastbar; datetime prevBar=lastbar; lastbar=Time[0]; return prevBar!=lastbar; }
- I disagree with making a new bar function, because it can only be called once
per tick. A variable can be tested multiple times.
Thanks whroeder1 !!!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello to everyone, I have a small problem using this code:
that helps me to read the code only once for each new bar. If time frame change, the buffers or objects are updated only after the new bar is formed, how can i fix this problem Without having to read the Tick Tick?