here is an example.
Enjoy it.
extern double perc_gain=1.0; // set to 1% by default. extern int slippage=1; void close_all_trades() { for(int i=OrdersTotal()-1;i>=0;i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES) ) continue; /* //some brokers require a delay not to consider scalp.... if(TimeCurrent()-OrderOpenTime()<90) continue; */ RefreshRates(); if(OrderType()==OP_BUY ) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),slippage,White); if(OrderType()==OP_SELL ) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),slippage,Red); } } int start() { double bal = AccountBalance(); double eq = AccountEquity(); double profit = eq-bal; double perc_profit = profit/eq*100.0; if(perc_profit >=perc_gain) close_all_trades(); return(0); }
if(perc_profit >=1.0) //??? if(perc_profit >=perc_gain) // ? i think you mean it this way...
meikel:
Indeed.
mistake solved. Thanks.

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
I know there are "close all orders" scripts out there but I haven't found one which will close all orders if proft > x% of equity. Can anyone help?
Thanks!