Download MetaTrader 5

Move to break even tool

To add comments, please log in or register
onisuk
29
onisuk  

Is there such a tool to move my stop to BE at a given price ?

I would ultimately like a line i can set like the take profit line, if price hits it stop is moved to entry price ..........

can anyone help me out?

 

cheers onis  

whroeder1
14779
whroeder1  
onis_uk: Is there such a tool to move my stop to BE at a given price ?
You have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
onisuk
29
onisuk  
ok thanks, added to the work que ! 
Donald Gibson
499
Donald Gibson  
onis_uk:

Is there such a tool to move my stop to BE at a given price ?

I would ultimately like a line i can set like the take profit line, if price hits it stop is moved to entry price ..........

can anyone help me out?

 

cheers onis  

//+------------------------------------------------------------------+
//Move to breakeven function
//+------------------------------------------------------------------+
void MoveToBreakeven()
  {
   int buymod=0;
   int sellmod=0;

   for(int b=OrdersTotal()-1; b>=0; b--)
     {
      if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
            if(OrderSymbol()==Symbol())
               if(OrderType()==OP_BUY)
                  if(OrderOpenPrice()>OrderStopLoss())
                     if(Bid-OrderOpenPrice()>PipsToLockIn*pips)
                        buymod=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+(PipsToLockIn*pips),OrderTakeProfit(),0,CLR_NONE);
     }
   for(int s=OrdersTotal()-1; s>=0; s--)
     {
      if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES))
            if(OrderSymbol()==Symbol())
               if(OrderType()==OP_SELL)
                  if(OrderOpenPrice()<OrderStopLoss())
                     if(OrderOpenPrice()-Ask>PipsToLockIn*pips)
                        sellmod=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-(PipsToLockIn*pips),OrderTakeProfit(),0,CLR_NONE);
     }
  }
To add comments, please log in or register