Change SL when is in profit?
Mitch Zanting:
If nobody wants to help you, send me a PM and at the beginning of the next week I should have some time.
Hello everyone,
Im looking for a way to modify the SL if the trade is for example in 100 points profit.
Can someone help with the code i need..
Mitch Zanting:
Hello everyone,
Im looking for a way to modify the SL if the trade is for example in 100 points profit.
Can someone help with the code i need..
If you're talking about TrailingStop - code from MT4 Samples:
double TrailingStop=100; for(int cnt=0;cnt<OrdersTotal();cnt++) { if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderType()<=OP_SELL && // check for opened position OrderSymbol()==Symbol()) // check for symbol { //--- long position is opened if(OrderType()==OP_BUY) { //--- should it be closed? //--- check for trailing stop if(TrailingStop>0) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()<Bid-Point*TrailingStop) { //--- modify order and exit if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green)) Print("OrderModify error ",GetLastError()); return; } } } } else // go to short position { //--- should it be closed? //--- check for trailing stop if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) { if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) { //--- modify order and exit if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red)) Print("OrderModify error ",GetLastError()); return; } } } } } }
Hello Friend,
I did something like this. I have not tested it yet. I hope it helps a little.
// Modify long Trade=OrderSelect(ClosePosition,SELECT_BY_TICKET); ask=Ask-OrderOpenPrice(); // TS=TrailingStop*Point; // TP=ask+TS;
You need something like this too.
double StopLevel=MarketInfo(NULL,MODE_STOPLEVEL)*_Point;
Hello everyone,
Im looking for a way to modify the SL if the trade is for example in 100 points profit.
Can someone help with the code i need..