i have an ea but i want to stop the maximal drwdon in % so i need a stoppoutpct! I copyied it from another ea but it doesn't work for my ea so i use the script - can anybody told me how i can use it
- How can I set auto stop loss ?
- Signal Transmitter/Receiver!
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
if((Balance.peak-Equity)/(Balance.peak/100)>=9){
//stopout
}
'Balance.peak' - variable not defined
'Equity' - variable not defined
What can i do=
Thanks for the fast answer! if the drawdown is over 15percent all orders should be closed! maybe with the magic number!
extern double StopLossPct = 100.0;if ((100 - StopLossPct) * AccountBalance() / 100.0 >= AccountEquity())
this works but it does not close the trades ?stoplosspct can be unique all orders have the same magic number
if ((100 - StopLossPct) * AccountBalance() / 100.0 >= AccountEquity()){
//stopout}
}
if ((100 - StopLossPct) * AccountBalance() / 100.0 >= AccountEquity()){
OrderClose(OrderTicket(), OrderLots(), Ask, 5);
OrderClose(OrderTicket(), OrderLots(), Ask, 5);
}
why does it not close`` i tried everything
Have you selected the order previously?
if ((20) * AccountBalance() / 100.0 >= AccountEquity())
OrderSelect(1, SELECT_BY_POS);
OrderClose(OrderTicket(), OrderLots(), Bid, 3, Violet);
OrderSelect(1, SELECT_BY_POS);
OrderClose(OrderTicket(), OrderLots(), Bid, 3, Violet);

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register