Help Spammed error messages in Journal

 
void EnterOppositeTrade()
  {
    
   
   tradeNumber=1;

   string cmt = (string)tradeNumber+" ";
   //Print("Entering Opposite Trade",cmt);      // Comment from CHART

   
   double SL= Bid+(StopLoss*pips); 
   //double Stoploss= NormalizeDouble(Sl,Digits);
   double price =Bid;
   double Pt= Bid-(Profit*pips);
   int Type= OP_SELL;    // default Buy Setting
    double lotsize = 0.01; //* MartingaleAmount;  // Leave Martingle as 1 if you choose to trade same risk and not more. Increasing lotsize is a double edged sword.
//sl=MACDBuyProfit, tp= MACDBuyProfit;

   if(TotalOpenOrders()==0)
     { int err=GetLastError();
       RefreshRates(); 
      if(rsiValue>=70)   //&& CandleDifference > 0.00250)  // Sell Trade  
        {
        //Print("Sell Stoploss:"+string(Sl));
        //Print("Sell price:" + string(price));
             // Reverse Trade
         ticket =  OrderSend(Symbol(),Type,lotsize,price,Slippage,SL,Pt,"Opposite Sell trade: " + cmt,magic,0,Magenta);
        }

      else
         if(rsiValue<=30)//&& //CandleDifference> 0.00250)  //Buy Trade
           {
            //Sl= Ask-(StopLoss*pips);
            //Print("Buy Stoploss:"+string(Sl));
            //Print("Buy price:" + string(price));
            Type= OP_BUY;
            price= Ask;
            Pt=Ask+(Profit*pips);
            SL= Ask-(StopLoss*pips);
            ticket =  OrderSend(Symbol(),Type,lotsize,price,Slippage,SL,Pt,"Opposite Buy trade: " + cmt,magic,0,Magenta);
           }

      //Comment(ScreenComment+"\nThis is trade number: "+(string)tradeNumber+"\nThe Lotsize is: "+DoubleToStr(lotsize,2));
      if(ticket<0)
        {
        if(err>1)
         Print("Could Not Place Opposite Trade: " + string(GetLastError()));
        }
     }

   else
      if(TotalOpenOrders()==1)
        {
         if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))   //else if you already have a position, update orders if need too.
           {
            Sleep(1000);
            RefreshRates();
            }
            int orderType = OrderType();// Short = 1, Long = 0
            double TakeProfit=OrderTakeProfit();
           
           
            if(orderType == 0)//long position
              {
                if(rsiValue>=70)
                TakeProfit= iOpen(NULL,0,0);
               
             }
                                                //optimalStopLoss = NormalizeDouble(stoploss,Digits);   // Profit I would like it to be  
            else //if short
              {
                if(rsiValue<=30)
                TakeProfit= iOpen(NULL,0,0);
                 
              }
          datetime ClosedOrder = OrderCloseTime();
              
          bool Ans =  OrderModify(ticket,OrderOpenPrice(),OrderStopLoss(),TakeProfit,0); 
              if(Ans==true)
              {
               if(ClosedOrder> 0)
                 {
                 Print ("Order Modefied! Ticket Number is:"+string(OrderTicket()));
                 Print("TakeProfit:"+DoubleToStr(TakeProfit,Digits));
                 }
               return;
               }
            else
           {int err=GetLastError();
            if(err!=err)
            {
            Print("Encountered an error during modification!"+(string)err+" "+ErrorDescription(err));
            }
           }
           
      }
             
                
 }

Hello I need help locating my code issue:
     I keep getting spammed in my Back-test journal "Order Modify error 1".
I am having trouble locating the issue. Would appreciate if another set of eyes took a look. Thank You.

*Disregard Blocked out code and comments made on EA. Was troubleshooting earlier. 

 

When modifying a trade always make sure that you are actually changing the values first.

If you try to modify the TP with the same value as the trade's TP, you will get the error.

 
Keith Watford:

When modifying a trade always make sure that you are actually changing the values first.

If you try to modify the TP with the same value as the trade's TP, you will get the error.

Thank You. That makes sense. I will go ahead and fix that.