Sleep only effects the EA from which it is called. If you use this in the Strategy Tester you should be aware that some functions are "
processed/passed without output " in the Strategy tester . . . Sleep() is one of them, more info here:
Testing Features and Limits in MetaTrader 4 - MQL4 Articles
- If you use Bid and Ask then you MUST call RefreshRates() after the Sleep().
- If you want the delay to work in the tester try:
int start(){ static datetime delay; if (TimeCurrent() < delay) return(0); static int next; if (next == SignalBUY){ next = SignalNone; int ticket = OrderSend(... } else{ : if (ConditionToBUY) { next = SignalBuy; delay = TimeCurrent() + 5; // 5 seconds } } }
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 forum,
It saw some issues in the past with Sleep(), but before I move on to alternatives (eg https://www.mql5.com/en/articles/1558 ) I am also not sure I got it right. Two issues:
1) In this EA I want to delay the buy/sell signal by 5 seconds, so under the MyEntrySignal() function I wrote something like below, but there is no delay so I'm surely missing something...
2) If I am using the Sleep() function in one of two EA's with the same Magic number - will the sleep affect both EAs or just his home EA?
Any insight ~most welcome!!!
Dan