ordermodify error 130

 
hello. I've just upgraded from MT4 build201 to MT4 build207. an EA of mine that used to work just fine with build201 has begun to give me repeated error messages: ordermodify error 130. I didn't do any modification to the EA, and the same EA when switched back to build201 worked with no error message. below is the related function that has been causing the error message. (the newSL variable is normalized).

this code is very simple and straightforward. I checked again and again but just couldn't figure out what's causing the error messages. could someone please shed some light on this?



int ModifySL(double newSL)
{
//----
int i,total,tries;
//----
total = OrdersTotal();
//----
for(i=total;i>=0;i--){
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()==magic_base){
if(newSL>0.0 && (OrderStopLoss()<=0.0 || OrderStopLoss()<newSL))
OrderModify(OrderTicket(),OrderOpenPrice(),newSL,OrderTakeProfit(),0,clr_modify);
}
if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==magic_base){
if(newSL>0.0 && (OrderStopLoss()<=0.0 || OrderStopLoss()>newSL))
OrderModify(OrderTicket(),OrderOpenPrice(),newSL,OrderTakeProfit(),0,clr_modify);
}
}
}
//----
return(0);
}
 
here is the function in my EA that calls the above ModifySL() function and passes the newSL variable to it.

int GetOpenSignal()
{
int precision = MarketInfo(Symbol(),MODE_DIGITS);

//---- check for long signal
if(newLow>pastLow+diff*Point){
GoLongNow = True;
GoShortNow = False;
longEntry = NormalizeDouble(High[1]+(Filter+Spread)*Point,precision); // this line of code calculates entry price for a long signal. if at the same time a short position is present, the long entry price also becomes the

new stoploss for the short entry.
}
//---- check for short signal
if(newHigh<pastHigh-diff*Point){
GoLongNow = False;
GoShortNow = True;
shortEntry = NormalizeDouble(Low[1]-Filter*Point,precision);
}
//---- long signal
if(GoLongNow==True && ForbidLong==False){the
//----
DeletePending();
//----
if(ExitNow==True) ClosePositions();
else ModifySL(longEntry); // this calls for the above ModifySL() function and passes the longEntry variable as the new stoploss for existing short positions.
//---- send signal to go long
return(OP_BUYSTOP);
}
//---- short signal
if(GoShortNow==True && ForbidShort==False){
//----
DeletePending();
//----
if(ExitNow==True) ClosePositions();
else ModifySL(shortEntry);
//---- send a signal to go short
return(OP_SELLSTOP);
}
//---- send signal to do nothing
return(-1);
}

to the best of my knowledge, I couldn't see anything wrong with this function. not to mention that it works just fine with MT4 build201. does this suggest that there may be a bug with the latest build of MT4?
 
I think the new Stop Loss level equal the OrderStopLoss(). Check values before trying to modify SL or TP .
 
Hello Rosh. thank you for your reply. However I don't think that is the problem with my EA.

if(newSL>0.0 && (OrderStopLoss()<=0.0 || OrderStopLoss()<newSL))
OrderModify(OrderTicket(),OrderOpenPrice(),newSL,OrderTakeProfit(),0,clr_modify);

this line of code has made sure that only a newSL that is greater than the current orderstoploss() will be used to modify the existing long position. If the new Stop Loss level equals to the current orderstoploss(), the EA simply ignores it and gets on with the next iteration.

take into account the fact that my EA worked and still works fine with earlier builds of MT4. I'd venture to suggest that this problem is either caused by a bug in the latest builds, or related to the grammatical changes in MQL. could somebody please shed some light on this?
Reason: