Breakeven code not working in MT5,

JIGNESH PATEL
22
I am tying to code breakeven in mt5 but it is not working, please help with correct code;
void Breakeven_Check()
  {
   for(int i=PositionsTotal()-1; i>=0; i--)
     {
      if(m_position.SelectByIndex(i))

         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==MagicNumber)
           {
            //--- calculate the current price levels
            //--- if the minimum allowed offset distance in points from the current close price is not set
            double B_point=(m_position.TakeProfit()-m_position.PriceOpen())/BEPoint;
            double S_point=(m_position.PriceOpen()-m_position.TakeProfit())/BEPoint;
            double Buy_SL=(m_position.PriceOpen()+(B_point/BEProfit));
            double Sell_SL=(m_position.PriceOpen()-(S_point/BEProfit));
            double B_Point1=m_position.PriceOpen() +B_point;
            double S_Point1 =m_position.PriceOpen() -S_point;


            if(m_position.PositionType()==POSITION_TYPE_BUY)
              {
               if(m_position.PriceCurrent()> B_Point1)

                  if(m_position.StopLoss()< m_position.PriceOpen())

                    {
                     if(!m_trade.PositionModify(m_position.Ticket(),Buy_SL,m_position.TakeProfit()))

                        Print("Modify ",m_position.Ticket(),

                              " Position -> false. Result Retcode: ",m_trade.ResultRetcode(),

                              ", description of result: ",m_trade.ResultRetcodeDescription());

                     continue;

                    }
              }
            else
              {
               if(m_position.PriceCurrent() <  S_Point1)
                  if(m_position.StopLoss() >m_position.PriceOpen())

                    {
                     if(!m_trade.PositionModify(m_position.Ticket(),Sell_SL, m_position.TakeProfit()))

                        Print("Modify ",m_position.Ticket(),

                              " Position -> false. Result Retcode: ",m_trade.ResultRetcode(),

                              ", description of result: ",m_trade.ResultRetcodeDescription());

                    }

              }



           }

     }
  }