# OrderModify Error 130 even when stoploss is set to zero?

113

How is this possible? I'm getting a few ordermodify error 130 here and there even though I have my stoploss set to 0
1399

113

```double Pips()
{
double pips;
pips=Point;
int digit;
digit=Digits();
int DR;
DR=digit%2;
if(DR==1)
{
pips*=10;
}
return(pips);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Price()
{
string a;
a=Symbol();
double b;
b=MarketInfo(a,MODE_BID);
int c;
c=Digits();
double d;
d=NormalizeDouble(b,c);
return(d);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double StopLevel()
{
string a;
a=Symbol();
double b;
b=MarketInfo(a,MODE_STOPLEVEL);
int c;
c=Digits();
int d;
d=c%2;
double e;
if(d==1)
{
e=b/10;
}
else
{
e=b;
}
return(e);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
{
string s;
s=Symbol();
double l;
l=lot;
int ticket;
if(ticket!=-1)
{
double sl;
if(RealStopLoss>0)
{
double a;
a=StopLevel();
double b;
b=MathMax(RealStopLoss,a);
double c;
c=Pips();
}
else
{
sl=0;
}
double tp;
if(TakeProfit>0)
{
double a;
a=StopLevel();
double b;
b=MathMax(TakeProfit,a);
double c;
c=Pips();
}
else
{
tp=0;
}
if((tp>0) || (sl>0))
{
bool a;
if(a==true)
{
double b;
b=OrderOpenPrice();
bool c;
c=OrderModify(ticket,b,0,tp,0,clrNONE);
}
}
}
return(ticket);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int SendSell(double lot)
{
string s;
s=Symbol();
double l;
l=lot;
int ticket;
ticket=OrderSend(s,OP_SELL,l,Bid,7,0,0,NULL,MagicNumber,0,clrRed);
if(ticket!=-1)
{
double sl;
if(RealStopLoss>0)
{
double a;
a=StopLevel();
double b;
b=MathMax(RealStopLoss,a);
double c;
c=Pips();
sl=Bid+b*c;
}
else
{
sl=0;
}
double tp;
if(TakeProfit>0)
{
double a;
a=StopLevel();
double b;
b=MathMax(TakeProfit,a);
double c;
c=Pips();
tp=Bid-b*c;
}
else
{
tp=0;
}
if((tp>0) || (sl>0))
{
bool a;
if(a==true)
{
double b;
b=OrderOpenPrice();
bool c;
c=OrderModify(ticket,b,0,tp,0,clrNONE);
}
}
}
return(ticket);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ModifyTP(double tp)
{
double a;
a=tp;
int b;
b=OrdersTotal();
for(int i=0;i<b;i++)
{
bool c;
if(c==true)
{
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;
j=OrderTicket();
double k;
k=OrderOpenPrice();
//double l;
//l=OrderStopLoss();
double sl1;
if(RealStopLoss>0)
{
double aa;
aa=StopLevel();
double bb;
bb=MathMax(RealStopLoss,aa);
double cc;
cc=Pips();
}
else{
sl1=0;}
bool m;
m=OrderModify(j,k,0,a,0,clrNONE);
}
}
}
}```
113

It apparently is a TP issue, not a SL issue.
Moderator
10617

Your code is long-winded and very difficult to follow

`i2=((g==true) && (h!=a));`

You are comparing doubles and we have no idea whether a is normalised or not

Check that they differ by at least 1 Point.

Moderator
10617

Your code can be reduced greatly by not re-assigning values of existing variables to different variables. Use the original variable. It is then easier for others to follow. Not only that, but if you come back to the code in a months time, it will be easier for YOU to follow

```void ModifyTP(double tp)
{
//double a;
//a=tp;
//int b;
//b=OrdersTotal();
for(int i=0;i<OrdersTotal();i++)
{
//bool c;
//if(c==true)
{
//string d;
//d=OrderSymbol();
//int e;
//e=OrderMagicNumber();
//string f;
//f=Symbol();
//bool g;
//g=(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber);
//double h;
//h=OrderTakeProfit();
//bool i2;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && (OrderTakeProfit()!=tp))
//if(i2==true)
{
//int j;
//j=OrderTicket();
//double k;
//k=OrderOpenPrice();
//double l;
//l=OrderStopLoss();
double sl1;
if(RealStopLoss>0)
{
//double aa;
//aa=StopLevel();
//double bb;
double bb=MathMax(RealStopLoss,StopLevel());
//double cc;
//cc=Pips();
}
else{
sl1=0;}
bool m;
m=OrderModify(OrderTicket(),OrderOpenPrice(),0,tp,0,clrNONE);
}
}
}
}```

Not only that, none of the highlighted code is used.

So your many lines of code in the ModifyTP function can be reduced to

```void ModifyTP(double tp)
{
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && (OrderTakeProfit()!=tp))
{
bool m;
m=OrderModify(OrderTicket(),OrderOpenPrice(),0,tp,0,clrNONE);
}
}
}```

much easier to read without having to keep looking back to see what variable a,j,k is etc

1399

Common logic mistakes. It's ok. I bet when he look at the code when he realized what he have done, he will be ROFL. XD