To use chat, please login.
Back to contacts

Random sleep

Jun 01 2016 at 06:25
25 ieraksti

I try to code a random sleep time before opening each trade to avoid opening 2 trades simultaneously when my EA is on multiples charts.

If(OrdersTotal()==0 && condition for buy) {

             ((Randon sleep here)) //open the trade wich has lowest sleep first, then OrdersTotal()==1, avoid 2nd trade to open.


Could someone help ma please?

Thank you

Ivan (StoneHeart)
Jun 01 2016 at 08:47
131 ieraksti
You can use 'GlobalVariable' :

When some EA send order, this variable accept the time of execution.
Each EA can make anything, only after N seconds (and again set this variable).

It is also useful to check IsTradeContextBusy() before execution,
it is possible some EA is already working.

Jun 03 2016 at 08:14
25 ieraksti
Thank you Yvan. I will try with IsTradeContextBusy()

Lūdzu ienāciet, lai komentētu.