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@
로그인 / 가입하기 to comment
You must be connected to Myfxbook in order to leave a comment
*상업적 사용 및 스팸은 허용되지 않으며 계정이 해지될 수 있습니다.
팁: 이미지/유튜브 URL을 게시하면 게시물에 자동으로 삽입됩니다!
팁: @기호를 입력하여 이 토론에 참여하는 사용자 이름을 자동으로 완성합니다.