Random sleep

Jun 01, 2016 at 06:25
595 व्यू
2 Replies
तबसे मेंबर है Sep 04, 2014   25 पोस्टों
Jun 01, 2016 at 06:25
Hello,

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.

OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"Trend",1000,0,Green);
}

Could someone help ma please?

Thank you
luclevesque17@
forex_trader_25447
तबसे मेंबर है Dec 21, 2010   127 पोस्टों
Jun 01, 2016 at 08:47
You can use "GlobalVariable" : https://docs.mql4.com/globals

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.
तबसे मेंबर है Sep 04, 2014   25 पोस्टों
Jun 03, 2016 at 08:14
Thank you Yvan. I will try with IsTradeContextBusy()
luclevesque17@
You must be connected to Myfxbook in order to leave a comment
*व्यवसायिक इस्तेमाल और स्पैम को ब्रदाश नहीं किया जाएगा, और इसका परिणाम खाता को बन्द करना भी हो सकता है.
टिप: किसी चित्र या यूट्यूब या URL को पोस्ट करने से वे अपने आप आपके पोस्ट में आजाएगा!
टिप: @ चिन्ह को टाइप करें उपभोगता के नाम को अपने आप करने के लिए जो इस चर्चा में भाग ले रहा है.