Yet you posted code that already has two delays.
Yet you posted code that already has two delays.
I am talking about before not after.
As @William Roeder wrote ' Yet you posted code that already has two delays.' Use the delay before execution of CloseAll(). Right now it gets executed instantly if;
op >= Profit
and you don't want that. You want the delay before it happens right....
As @William Roeder wrote ' Yet you posted code that already has two delays.' Use the delay before execution of CloseAll(). Right now it gets executed instantly if;
and you don't want that. You want the delay before it happens right....
is this gonna work?
int sec; void OnTick() { //+------------ double op = CalculateProfit(); if (op >= Profit ) { sec = Seconds() ; if (sec >=25) { CloseAll(); SendNotification("Trade is end1"); Sleep(60*60000);// 60.000 = 1 min SendNotification("Trade is end2"); Sleep(60*60000);// 60.000 = 1 min }} //+---------------- }Just want to inform that all this testing I am doing for demo account, I guess this should not affect.
-
“Doesn't work” is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
How To Ask Questions The Smart Way. 2004
When asking about code -
Sleep does not work in the tester.
- After Sleep and between server calls the market will have changed. You must update your Predefined Variables or series arrays before using any of them — you must call RefreshRates. RefreshRates updates:
Predefined variables: Ask, Bars, Bid, Close[], High[], Low[], Open[], Point, Time[], Volume[]
RefreshRates - Timeseries and Indicators Access - MQL4 Reference
Predefined Variables - MQL4 Reference
Also updates: Hour, Minute, and Seconds
Minute() returns wrong values - or am I wrong? - MQL4 programming forum
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am trying to find the way how to delay my function CloseAll (closing all orders) before it will execute.
So once EA see profit it should pause for couple seconds (let say for 10 sec) and after CloseAll will take place.
here is my part of EA. Could you please advise what to add ?