Hello,
I’m looking for a script or indicator who can close all position on one chart when the Drawdown on it’s chart is 10% for exemple.
I have already the code for a script who close all trade when i put it on a chart.
Know i’m looking for add an condition like
If DrawDown == -500 or 10% for example, the script while be execute and close all positions.
I’m going to try to put the code in this post.
If the script or indicator can also delete the Expert Advisor on this chart to stopped it it’s good
So that is all that i have for that, i try on metaEditor but it’s difficult.
Thanks for your help
sinput int RTOTAL = 4; // Число повторов при неудачных сделках
sinput int SLEEPTIME = 1; // Время паузы между повторами в секундах
sinput int Deviation_ = 10; // Отклонение цены
sinput bool exAllSymbols = false; // false - только текущий, true - все символы
#define _CS(A) ((!IsStopped()) && (A))
bool CloseAllPositions( const bool AllSymbols = true, const int Slippage = 0 )
{
bool Res = true;
for (int i = OrdersTotal() - 1; _CS(i >= 0); i–)
if (OrderSelect(i, SELECT_BY_POS) && (OrderType() <= OP_SELL) &&
(AllSymbols ? true : (OrderSymbol() == Symbol())))
Res &= OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage);
return(Res);
}
void OnStart()
{
for (int i = 0; CS((i < RTOTAL) && (!CloseAllPositions(exAllSymbols, Deviation))); i++)
Sleep(SLEEPTIME * 1000);
}