this is my code:I have tried it several times with different conditions.thanks for(cnt=0;cnt 0) { if(Bid-OrderOpenPrice()>MarketInfo(Symbol(),MODE_POINT)*TrailingStop) { if(OrderStopLoss() isar(NULL,15,0.02,0.2,0)) { OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position return(0); // exit } } // check for trailing stop if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MarketInfo(Symbol(),MODE_POINT)*TrailingStop)) { if((OrderStopLoss()>(Ask+MarketInfo(Symbol(),MODE_POINT)*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MarketInfo(Symbol(),MODE_POINT)*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } }
- MQL4 Learning
- Help! - Is it possible to add Trailing Stop on OrderSend? I need trailing Stop on every new order placed.
- EA Coding support !
Translated
for(cnt=0;cnt 0) { if(Bid-OrderOpenPrice()>MarketInfo(Symbol(),MODE_POINT)*TrailingStop) { if(OrderStopLoss() isar(NULL,15,0.02,0.2,0)) { OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position return(0); // exit } } // check for trailing stop if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MarketInfo(Symbol(),MODE_POINT)*TrailingStop)) { if((OrderStopLoss()>(Ask+MarketInfo(Symbol(),MODE_POINT)*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MarketInfo(Symbol(),MODE_POINT)*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } }
Does this compile?
Please post code with the SRC button :)
Code as seen cannot work as no OrderSelect() has been done - you have to track the ticket number or loop through the pool of orders to grab an order then evaluate then Close.
Good luck
-BB-

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