Edit Your Comment
CloseAllAtEquityLevel
會員從Apr 17, 2012開始
9帖子
May 04, 2012 at 02:46
會員從Nov 27, 2010開始
244帖子
More specifics would help.
By the title, it also sounds more like a trade management EA. Steve Hopwood wrote an excellent Multi Purpose Trade Management EA (MPTM). Read its documentation, it'd probably do what you want.
That said:
extern bool EquityStopLoss = TRUE;
extern double EquityPercent = 10.0; //for 10% drawdown
int start(){
if(EquityStopLoss&&1-AccountEquity()/AccountBalance()>EquityPercent/100){ //if drawdown exceeds 10%
CloseAll(); //Close all trades
}
}
void CloseAll(){ //Close all BUY and SELL orders including Pending Orders if any
bool result=false;
for(int i=OrdersTotal()-1;i>=0;i--){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)result=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),MaxSlippage*mt,Blue);
if(result==false){
Print("CloseAll failed with error#",GetLastError());
continue;
}
}
}
By the title, it also sounds more like a trade management EA. Steve Hopwood wrote an excellent Multi Purpose Trade Management EA (MPTM). Read its documentation, it'd probably do what you want.
That said:
extern bool EquityStopLoss = TRUE;
extern double EquityPercent = 10.0; //for 10% drawdown
int start(){
if(EquityStopLoss&&1-AccountEquity()/AccountBalance()>EquityPercent/100){ //if drawdown exceeds 10%
CloseAll(); //Close all trades
}
}
void CloseAll(){ //Close all BUY and SELL orders including Pending Orders if any
bool result=false;
for(int i=OrdersTotal()-1;i>=0;i--){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)result=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),MaxSlippage*mt,Blue);
if(result==false){
Print("CloseAll failed with error#",GetLastError());
continue;
}
}
}
Consistency above all.
會員從Apr 17, 2012開始
9帖子
May 10, 2012 at 18:37
會員從Apr 17, 2012開始
9帖子
Raiden posted:
More specifics would help.
By the title, it also sounds more like a trade management EA. Steve Hopwood wrote an excellent Multi Purpose Trade Management EA (MPTM). Read its documentation, it'd probably do what you want.
That said:
extern bool EquityStopLoss = TRUE;
extern double EquityPercent = 10.0; //for 10% drawdown
int start(){
if(EquityStopLoss&&1-AccountEquity()/AccountBalance()>EquityPercent/100){ //if drawdown exceeds 10%
CloseAll(); //Close all trades
}
}
void CloseAll(){ //Close all BUY and SELL orders including Pending Orders if any
bool result=false;
for(int i=OrdersTotal()-1;i>=0;i--){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)result=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),MaxSlippage*mt,Blue);
if(result==false){
Print("CloseAll failed with error#",GetLastError());
continue;
}
}
}
Thank you for the answer!
I dont know much about Metaquotes... How can I change the percentage?
If I want that it closes all my operations if the equity reaches 20% decrease... fore example... What Should I do?
會員從Apr 17, 2012開始
9帖子
May 11, 2012 at 02:14
會員從Nov 27, 2010開始
244帖子
You could copy that text, open the Meta Editor, and paste that into an EA. (There are two more variables that need to be defined though.)
But you should skip that and just use the Multi Purpose Trade Management EA by Steve Hopwood in the forexfactory.com link.
But you should skip that and just use the Multi Purpose Trade Management EA by Steve Hopwood in the forexfactory.com link.
Consistency above all.
會員從Dec 15, 2010開始
784帖子
May 31, 2012 at 01:56
會員從Nov 27, 2010開始
244帖子
I've written the EA, you can find it here.
http://raidenworks.com/2012/05/31/drawdown-percent-close-ea/
http://raidenworks.com/2012/05/31/drawdown-percent-close-ea/
Consistency above all.
會員從May 30, 2012開始
124帖子
會員從Dec 15, 2010開始
784帖子
Nov 08, 2016 at 07:25
會員從Jul 07, 2016開始
1帖子
Hi Raiden.
I like your indicator but need update.
Please update your indicator with new MQL4 language. (The MQL4 language has significantly changed since build 600 in the beginning of 2014).
If I cannot update it, the guidelines me to update it. I am a novice in MQL
I like your indicator but need update.
Please update your indicator with new MQL4 language. (The MQL4 language has significantly changed since build 600 in the beginning of 2014).
If I cannot update it, the guidelines me to update it. I am a novice in MQL

*商業用途和垃圾郵件將不被容忍,並可能導致帳戶終止。
提示:發佈圖片/YouTube網址會自動嵌入到您的帖子中!
提示:鍵入@符號,自動完成參與此討論的用戶名。