English

## Break even / trailing stop

 120 DeanDeV 2015.05.12 10:54   Hi guys,If I place an order of let's say take profit 500 and stop loss 100. I want the order to break even when it gets to 100 profit (which is easy enough to code) however, I want the stop loss to move up every 100 pips (not trail) by 100 pips. So it will take incremental steps towards the take profit. In other words it must "break even" every 100 pips adding an additional 100 pips to the stop loss. I have coded the first step but not sure how to make it move step by step. Here is my break even code: ```void MoveToBreakeven()                 //Breakeven function    {       for(int b=OrdersTotal()-1; b >= 0; b--)       {       if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))          if(OrderMagicNumber()==MagicNumber)      //correct order             if(OrderSymbol()==Symbol())            //correct pair                if(OrderType()==OP_BUY)             //correct buy                if(OrderOpenPrice()>OrderStopLoss())                   if(Bid-OrderOpenPrice()>WhenToMoveToBE*Point)    //how far has the bid moved from opening                      int buyticket1=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-(PipsToLockIn*Point),Digits),OrderTakeProfit(),0,clrBlue);       }              for(int s=OrdersTotal()-1; s>=0; s--)          {                        if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES))             if(OrderMagicNumber()==MagicNumber)                if(OrderSymbol()==Symbol())                   if(OrderType()==OP_SELL)                                             if(OrderOpenPrice()WhenToMoveToBE*Point)                            int sellticket1=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+(PipsToLockIn*Point),Digits),OrderTakeProfit(),0,clrRed);           }       } ``` If there is any way to edit it to make it move step by step that would help a lot!
 12985 WHRoeder 2015.05.12 19:13 #   ```if(Bid-OrderOpenPrice()>WhenToMoveToBE*Point)    //how far has the bid moved from opening   int buyticket1=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-(PipsToLockIn*Point```What you wrote was a trailing SL. What you need is two critera A) below BE move when market reaches 100 pips. B) above(at) BE move when market reaches 200 pips above SL.
 120 DeanDeV 2015.05.12 20:10 #   WHRoeder: What you wrote was a trailing SL. What you need is two critera A) below BE move when market reaches 100 pips. B) above(at) BE move when market reaches 200 pips above SL.Okay, that logic helps.. So something like this...```void MoveToBreakeven()                 //Breakeven function    {       for(int b=OrdersTotal()-1; b >= 0; b--)       {       if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))          if(OrderMagicNumber()==MagicNumber)      //correct order             if(OrderSymbol()==Symbol())            //correct pair                if(OrderType()==OP_BUY)             //correct buy                                 if(Bid-OrderOpenPrice()>WhenToMoveToBE1*Point)    //how far has the bid moved from opening                     if(OrderOpenPrice()>OrderStopLoss())                      int buyticket1=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-(PipsToLockIn*Point),Digits),OrderTakeProfit(),0,clrBlue);                   if(Bid-OrderOpenPrice()>WhenToMoveToBE2*Point)                     if(OrderOpenPrice()>OrderStopLoss())                      int buyticket2=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-(PipsToLockIn*Point),Digits),OrderTakeProfit(),0,clrBlue);       }              for(int s=OrdersTotal()-1; s>=0; s--)          {                        if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES))             if(OrderMagicNumber()==MagicNumber)                if(OrderSymbol()==Symbol())                   if(OrderType()==OP_SELL)                                                                 if(OrderOpenPrice()-Ask>WhenToMoveToBE1*Point)                        if(OrderOpenPrice()WhenToMoveToBE2*Point)                        if(OrderOpenPrice()
 120 DeanDeV 2015.05.13 17:44 #   WHRoeder: What you wrote was a trailing SL. What you need is two critera A) below BE move when market reaches 100 pips. B) above(at) BE move when market reaches 200 pips above SL.Okay this works:  ```void MoveToBreakeven()                 //Breakeven function    {       for(int b=OrdersTotal()-1; b >= 0; b--)       {       if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))          if(OrderMagicNumber()==MagicNumber)      //correct order             if(OrderSymbol()==Symbol())            //correct pair                if(OrderType()==OP_BUY)             //correct buy                                  if(OrderOpenPrice()>OrderStopLoss())                       if(Bid-OrderOpenPrice()>WhenToMoveToBE1*Point)    //how far has the bid moved from opening                     int buyticket1=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-(PipsToLockIn*Point),Digits),OrderTakeProfit(),0,clrBlue);                                                                 if(Bid-OrderOpenPrice()>WhenToMoveToBE2*Point)                       if(buyticket1>0)                                             int buyticket2=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-(PipsToLockIn*Point),Digits),OrderTakeProfit(),0,clrBlue);       }       ``` Thanks for the help.
 250 ffoorr 2015.05.13 19:25 #   something like that maybe : ` if(Bid > OrderStoploss() +step*Point)   `