That code means that any code that follows will only be executed if a new bar opens in the stipulated timeframe.
Obviously a lot quicker than when the full code executes every tick.
Many strategies, such as MA crosses or stochastic/RSI crossing certain levels are coded to only execute when a bar closes (ie new bar opens).
This is to avoid (what some people consider) false signals when a cross happens while the bar is still open, but crosses back before the bar has closed.
I wonder why "CheckValueTime" variable remember previous value instant of reset to zero when EA execute again.
I just declare in normal variable not global variable.
I wonder why "CheckValueTime" variable remember previous value instant of reset to zero when EA execute again.
I just declare in normal variable not global variable.
If the variable is declared locally and not static, it will not be remembered and the code will not be effective.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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 got this code from other forum and I have this code in my ea too.
And I got a different results between with and with out this code.
With this code it's can run optimization faster than without.
I am not sure with or without this code that make EA realistic.
Please anyone suggest to me or if anyone has a better like this code I would be appreciate.