OrderModification Error 1 and 130

 

i keep getting OrderModification Error 1 and 130, but the ordermodification works perfectly, can some one help me find out why.

my code:

double SL_BUY = Low[iLowest(NULL, 0, MODE_LOW, 3, 1)]; //trailing stoploss

SL_Min = MarketInfo(Symbol(),Mode_StopLevel)*Point; // minimum stoploss distance

if( Bid > SL_BUY && MathAbs(Bid - SL_BUY) >= SL_Min && SL_BUY != _OrderStopLoss[n])

{

OrderModify(_OrderTicket[n], _OrderOpenPrice[n], SL_BUY, 0, 0, MediumSeaGreen); // ordermodify

}


 
What do Error 1 and Error 130 mean ? did you look them up ?
 

indeed I checked the meaning, thats why I added

MathAbs(Bid - SL_BUY) >= SL_Min

but error still there.

 

Error 1 : I guess you are trying to modify the same order and set the same SL, i.e. not modifying anything . .

Error 130 : this may help you https://book.mql4.com/appendix/limits

I think your MarketInfo call is wrong, shouldn't it be MODE_STOPLEVEL ? and maybe this MathAbs(Bid - SL_BUY) >= SL_Min should be change to this MathAbs(Bid - SL_BUY) > SL_Min

When you do the order modify do you update your _OrderStopLoss array with the new SL value ? I can't see it in your code . . .

 
I used below code to prevent modifying the same SL, I think it does have something to do with Array, its not updated. thanks for pointing out.
SL_BUY != _OrderStopLoss[n]

yes it is MODE_STOPLEVEL, wrong typing...

Reason: