Hello friends. How do we ensure that an operation is performed only once in the OnTick function.
Burhan Ozdemir:
Hello friends. How do we ensure that an operation is performed only once in the OnTick function.
By using OnTick(), each tick the EA will do what you want unlimited time.. Hello friends. How do we ensure that an operation is performed only once in the OnTick function.
In case you wish to do once or even more specified ticks then let me share some trick with you.
Using the iVolume could support you when it is used with < operator.
So:
if (iVolume(symbol, timeframe, shift) < 2)
{
then do something;
}
The shift most be 0
The above answer is not the professional solution, it is just a quick trick
Muhammed Abdulwadud Soubra # :
Onun tiklerini zaman zaman söylerken söyler..
Thanks Bro I will try
Onun tiklerini zaman zaman söylerken söyler..
Bir veya daha fazla belirlikene yapmak isterseniz, o zaman herkesle bir numara paylaşmama izin verin.
iVolume'u kullanmak, operatörden daha azıyla destek olabilir
Yani:
if (iVolume(sembol, zaman çerçeve, vardiya) < 2) o bir şeyler yapın
Burhan Ozdemir: . How do we ensure that an operation is performed only once in the OnTick function.
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)
![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