i need a code to stop it from reentering an order when the buy side is in profit with a trailing stop.
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
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);}
}