Hi, i have ea and i cant figure what should i remove from it so it can only close all open orders once it reaches the %equity we set in ea, right now what happens is the ea calculate the floating and balance as well ! all i want simple if it reaches the equality we set even the balance is in negative it should stop all orders!
Code is below: and screenshot as well:
Code :
floatingProfit=fpl;
if (MaxDrawdown!=0 && startBalance!=0 && fpl<0 && -(fpl+GVGet("CPL"))/startBalance*100>=MaxDrawdown)
{
Print("try to close all orders and stop ea on MaxDrawdown(dd="+DoubleToStr(-(fpl+GVGet("CPL"))/startBalance*100, 2)+", MaxDrawdown="+DoubleToStr(MaxDrawdown, 2)+")");
CloseAllOrders("", -1);
ExpertRemove();
}
datetime today = StringToTime(TimeToStr(TimeCurrent(), TIME_DATE));
if (CloseEquityDollar!=0 && floatingProfit>=CloseEquityDollar)
{
Print("try to close all orders on CloseEquityDollar (fpl="+DoubleToStr(floatingProfit, 2)+", target="+DoubleToStr(CloseEquityDollar, 2)+")");
CloseAllOrders("", -1);
if (DayTradeOffOnClose) GVSet(IntegerToString(today)+".DayTradeOff", 1);
}
if (CloseEquityPercent!=0 && floatingProfit/AccountBalance()*100>=CloseEquityPercent)
{
Print("try to close all orders on CloseEquityPercent (fpl="+DoubleToStr(floatingProfit/AccountBalance()*100, 2)+", target="+DoubleToStr(CloseEquityPercent, 2)+")");
CloseAllOrders("", -1);
if (DayTradeOffOnClose) GVSet(IntegerToString(today)+".DayTradeOff", 1);
}
Code is below: and screenshot as well:
Code :
floatingProfit=fpl;
if (MaxDrawdown!=0 && startBalance!=0 && fpl<0 && -(fpl+GVGet("CPL"))/startBalance*100>=MaxDrawdown)
{
Print("try to close all orders and stop ea on MaxDrawdown(dd="+DoubleToStr(-(fpl+GVGet("CPL"))/startBalance*100, 2)+", MaxDrawdown="+DoubleToStr(MaxDrawdown, 2)+")");
CloseAllOrders("", -1);
ExpertRemove();
}
datetime today = StringToTime(TimeToStr(TimeCurrent(), TIME_DATE));
if (CloseEquityDollar!=0 && floatingProfit>=CloseEquityDollar)
{
Print("try to close all orders on CloseEquityDollar (fpl="+DoubleToStr(floatingProfit, 2)+", target="+DoubleToStr(CloseEquityDollar, 2)+")");
CloseAllOrders("", -1);
if (DayTradeOffOnClose) GVSet(IntegerToString(today)+".DayTradeOff", 1);
}
if (CloseEquityPercent!=0 && floatingProfit/AccountBalance()*100>=CloseEquityPercent)
{
Print("try to close all orders on CloseEquityPercent (fpl="+DoubleToStr(floatingProfit/AccountBalance()*100, 2)+", target="+DoubleToStr(CloseEquityPercent, 2)+")");
CloseAllOrders("", -1);
if (DayTradeOffOnClose) GVSet(IntegerToString(today)+".DayTradeOff", 1);
}
Rocks on Bull *
Bull on rocks V3 All Time Return:
na