Hi,
Sure, you can, in fact it is very simple to do. I'm not sure if you are using mql5 or mql4, but, in mql5, Sleep() does work in backtest, here are the documentaions:
Mql5: https://www.mql5.com/pt/docs/common/sleep
Mql4: https://docs.mql4.com/common/sleep
You can see that on the mql4 link, there is a note " Sleep() function does not suspend execution of the Expert Advisor in the Strategy Tester."
You also asked if you could trust Sleep() function, in the documentation linked above, you will see in the description that if you use this function that means that your code is entirely stoped for the specified time in seconds. Although , note that the SL an TP are on the server so, if the price hit any of them, even your code being stopped, they will be triggered .
With these details in mind, if you are using mql4, you can do it by checking the time with TimeCurrent(). All you need to do is to code it in a way that verify if it has already passed 10 minutes.
Hope I could help :-)

- www.mql5.com
iTime()
Record the bar open time of the M1 bar when you open the trade, then when the trade is closed you monitor as much M1 bars as you need for a pause.
Of course you can also use larger bars like H1 for 1 Hour pause and etc.

- www.mql5.com
You can use
Record the bar open time of the M1 bar when you open the trade, then when the trade is closed you monitor as much M1 bars as you need for a pause.
Of course you can also use larger bars like H1 for 1 Hour pause and etc.
thank you dear marco
please tell me more about this function
when i started to learn mql datetime function was Unkown for me cuz i cant understand it very well
Hi,
Sure, you can, in fact it is very simple to do. I'm not sure if you are using mql5 or mql4, but, in mql5, Sleep() does work in backtest, here are the documentaions:
Mql5: https://www.mql5.com/pt/docs/common/sleep
Mql4: https://docs.mql4.com/common/sleep
You can see that on the mql4 link, there is a note " Sleep() function does not suspend execution of the Expert Advisor in the Strategy Tester."
You also asked if you could trust Sleep() function, in the documentation linked above, you will see in the description that if you use this function that means that your code is entirely stoped for the specified time in seconds. Although , note that the SL an TP are on the server so, if the price hit any of them, even your code being stopped, they will be triggered .
With these details in mind, if you are using mql4, you can do it by checking the time with TimeCurrent(). All you need to do is to code it in a way that verify if it has already passed 10 minutes.
Hope I could help :-)
thanks dear bhjks
sorry if i forgot to say im using mql4
and i used this codes by the many ways but i dont know why it didnt worked
CloseOrderTime() , TimeCurrent() , ETC....
here is one of the way i tried to use
datetime pause = TimeMinute(OrderCloseTime())+Pasuing*60;
datetime now = TimeMinute(TimeCurrent());
void OnTick()
{
if(now>pause)
if(Close[1]>Close[2])
OrderSend()..........
but this date time code didnt worked
so is there any way to get time as a int number ????
like timetostr and turned into int by strtoint ?????
unfortunately i dont know what should i do to solve this problem :<
zogholme: sorry if i forgot to say im using mql4
datetime pause = TimeMinute(OrderCloseTime())+Pasuing*60; datetime now = TimeMinute(TimeCurrent()); void OnTick(){ if(now>pause)
so is there any way to get time as a int number ????
-
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time post in the correct place. The moderators will likely move this thread there soon. -
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor -
TimeMinute returns an int not a datetime.
-
Those are not assignments; they are initialization of a common (globally declared), or static variable with a constant. They work exactly the same way in MT4/MT5/C/C++.
-
They are initialized once on program load.
-
They don't update unless you assign to them.
-
In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use).
MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and
Don't try to use any price or server related functions in OnInit (or on load), as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
-
-
Time is an int (a datetime). Time plus constant is an int (a datetime). Simply compare the times.
if(TimeCurrent() - OrderCloseTime()) >= Pasuing*60) …
-
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time post in the correct place. The moderators will likely move this thread there soon. -
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor -
TimeMinute returns an int not a datetime.
-
Those are not assignments; they are initialization of a common (globally declared), or static variable with a constant. They work exactly the same way in MT4/MT5/C/C++.
-
They are initialized once on program load.
-
They don't update unless you assign to them.
-
In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use).
MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and
Don't try to use any price or server related functions in OnInit (or on load), as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
-
-
Time is an int (a datetime). Time plus constant is an int (a datetime). Simply compare the times.
sorry i didnt know that
what i have to do now
i learned mql4 recently and my knowlege of mql its too low
i have to delete this topic or will automatically delete ???
i have to delete this topic or will automatically delete ???
I have already moved this topic.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hey guys happy new year
i had reads a lot of topics about something like pause or rest or skip or etc.
for expert when it takes stoploss expert don't work or don't trade for a time that we want
so i tried to code something like datetime function
but i don't know i code it wrong or it didn't worked for me!!!!
then i want choose sleep() function but i find out this function doesn't work in strategy tester
my question is can i trust this function ???? when my expert got loss sleep for 10 minute ???
other way i can say it will skip candles for trading
best regards