OnTick
Hello friends. How do we ensure that an operation is performed only once in the OnTick function.
Onun tiklerini zaman zaman söylerken söyler..
| You test for that | bool isFirstTick; int OnInit(){ isFirstTick=true; … } void OnTick(){ if(isFirstTick){ isFirstTick=false; // Only first tick. } // Every tick. |
- OPs question was doing something once, not once per bar.
-
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)