Hello friends, I succeeded in building my expert advisor and its working but i have a challenge in the sell direction, i need a code to stop it from reentering an order when the buy side is in profit with a trailing stop. Both buy and sell enters order the same time with a stop loss level activated on both sides. Below is the code for order entry. Thanks for your assistance.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello friends, I succeeded in building my expert advisor and its working but i have a challenge in the sell direction, i need a code to stop it from reentering an order when the buy side is in profit with a trailing stop. Both buy and sell enters order the same time with a stop loss level activated on both sides. Below is the code for order entry. Thanks for your assistance.
void OrderEntry(int direction)
{
if(direction==0)
{
double bsl=0;
double btp=0;
if(StopLoss!=0)bsl=Ask-(StopLoss*Pips);
if(TakeProfit!=0)btp=Ask+(TakeProfit*Pips);
if(OpenOrdersThisPair(Symbol())<1)int buyticket = OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,0,0,NULL,MagicNumber,0,clrGreen);
if(buyticket>0)OrderModify(buyticket,OrderOpenPrice(),bsl,btp,0,CLR_NONE);}
if(direction==1)
{
double ssl=0;
double stp=0;
if(StopLoss!=0)ssl=Bid+(StopLoss*Pips);
if(TakeProfit!=0)stp=Bid-(TakeProfit*Pips);
if(OpenOrdersThisPair(Symbol())<2)int sellticket = OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,0,0,NULL,MagicNumber,0,clrRed);
if(sellticket>0)OrderModify(sellticket,OrderOpenPrice(),bsl,btp,0,CLR_NONE);}
}