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 need assistance to this EA, how to make "closeAllOrders" instruction when Last open order hit stopLoss.
Below is a EA, Thank You for kind assistance.
void OpenBuy()
{
double ldLot, ldStop, ldTake;
string lsComm;
ldLot = GetSizeLotS();
ldStop = Ask-Point*stopLossS;
ldTake = NormalizeDouble(GetTakeProfitBuy(),Digits);
lsComm = GetCommentForOrder();
// OrderSend(Symbol(),OP_BUY,ldLot,NormalizeDouble(Ask,Digits),Slippage,ldStop,ldTake,lsComm,0,0,NULL);
if (UseSound) PlaySound(NameFileSound);
}
void OpenSell()
{
double ldLot, ldStop, ldTake;
string lsComm;
ldLot = GetSizeLotB();
ldStop = Bid+Point*stopLossB;
ldTake = NormalizeDouble(GetTakeProfitSell(),Digits);
lsComm = GetCommentForOrder();
OrderSend(Symbol(),OP_SELL,ldLot,NormalizeDouble(Bid,Digits),Slippage,ldStop,ldTake,lsComm,0,0,NULL);
if (UseSound) PlaySound(NameFileSound);
}
void closeAllOrders(int type)
{
for(int c=0;c<OrdersTotal();c++)
{
OrderSelect(c,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderComment()==Name_Expert && OrderType()==OP_BUY && type==0)
{
OrderClose(OrderTicket(), OrderLots(),Bid,Slippage, White);
}
if (OrderSymbol()==Symbol() && OrderComment()==Name_Expert && OrderType()==OP_SELL && type==1)
{
OrderClose(OrderTicket(), OrderLots(), Ask,Slippage, White);
}
if (OrderSymbol()==Symbol() && OrderComment()==Name_Expert && OrderType() > 1) {OrderDelete(OrderTicket());
}
}
}