OrderModify error 1 in Trailing Stop

 

Hello, I have this code for the Trailing Stop of my EA, and it is generating the "OrderModify error 1", can you help me to know what I am doing wrong please?

int nbuy()
  {
   int b0=0;
   for(int i=0;i<OrdersTotal();i++)
     {
      int a1=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderType()==OP_BUY && OrderMagicNumber()==magic && OrderSymbol()==Symbol())b0++;
     }
   return(b0);
  }

//----------------------+

if(TS>0 && nbuy()>0)
     {
      for(int i=0;i<=OrdersTotal();i++)
        {
         int a2=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(OrderType()==0 && OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
           {
            if(Bid-OrderOpenPrice()>TS*Points && OrderStopLoss()<Bid-TS*Points)
              {
               bool mb=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TS*Points,0,0,clrNONE);
              }
           }
        }
     }

TS = 3

magic = Magic number