OrderModify Error 130 with no stop loss being used?

 
Why would I be getting error 130 (invalid stops) when I'm not even using a stoploss? The ordermodify function I used just uses OrderStopLoss() to set the SL when the order is modified to add the TP.
 
There are no mind readers here. You have to post the relevant code.
 
On your message entry area, there is a button marked "SRC" next to the camera icon.  Click that and post the code inside the opened area.
 
void ModifyTP(double tp)
  {
   double a;
   a=tp;
   int b;
   b=OrdersTotal();
   for(i=0;i<b;i++)
     {
      bool c;
      c=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(c==true)
        {
        //if(OrderType()==OP_SELL && a > Bid-StopLevel){ a = StopLevel;}
        //if(OrderType()==OP_BUY &&  a < Ask+StopLevel){ a = StopLevel;}
         string d;
         d=OrderSymbol();
         int e;
         e=OrderMagicNumber();
         string f;
         f=Symbol();
         bool g;
         g=((d==f) && (e==MagicNumber));
         double h;
         h=OrderTakeProfit();
         bool i2;
         i2=((g==true) && (h!=a));
         if(i2==true)
           {
            int j;
            int d=0;
            j=OrderTicket();
            double k;
            k=OrderOpenPrice();
            double l;
            l=OrderStopLoss();
            bool m;
            m=OrderModify(j,k,l,a,0,clrNONE);

                        int ERROR=GetLastError();
            while(m==false && d<= 5){


            if(ERROR==1 || ERROR==0)
            break;
            d=d+1;
            Print("Error in ModifyTP OrderModify. Error code=",+ERROR);
            Sleep(15000);
            RefreshRates();
            m=OrderModify(j,k,l,a,0,clrNONE);
            ERROR=GetLastError();
            }
            
           }
        }
     }
  }
 

Why write code with so many unnecessary substituted variables? Especially as the variable names do not help to identify what the variable is.

Your function has tp as a parameter. The name "tp" suggests take profit so that is good. Why then create a new variable and name it "a" , with the value of "tp"? Just use "tp".

Your use of substituted variables makes it difficult to follow the code. When you get on to more complicated coding, you will be unable to follow coding that you have written yourself.

 

When you print your error, print the values that are being modified. Probably you are using an invalid value for the take profit. 

 

What is recommended, even if it is just you looking at your code, is use variable names that make sense for what you are trying to use them for.  Like within your if (i2==true) section, having variables named j, k, l, and m will work, but if you are doing this all over your program, how much easier would it be if you could tell by looking at the variable name and be able to say, that variable (named currentOrderNumber) is holding the current order number.  Also, the way you have your program coded, the variables you are using, in some places, are only active within that section of code.  If the values you are feeding those variables are also used elsewhere in the rest of the program, you are adding unnecessary processing to your program, which can make it slower in the end.  If you are using those values elsewhere, create the variables outside of any methods, and make them program variables.  Also, using all caps in a name like your ERROR variable usually is reserved for constants, to make them easier to identify within the code.  Your section of code

                        int ERROR=GetLastError();
            while(m==false && d<= 5){


            if(ERROR==1 || ERROR==0)

looks to me like it could be 1 of 2 possible numbers (as in not a constant).  If it is supposed to be a boolean (0 or 1) that would work, however, it should be made a boolean, not an int, and also the name probably should be changed to lower case.