inconsistent ordermodify - 130 invalid stops

 

I attached the ea to 4 charts. I verified the values when I started having problems. The verified values are correct, but the ordermodify function does not actuate (Mod=0) and returns error 130 invalid stops.

Please review.

Thank you.

Rudy


if((typeb0s1==1 && SL>Bid+(Point*TrailingStop) && ticket!=0 && Symb==OrderSymbol()))
{
SL=0;
minstop=MarketInfo(Symb,MODE_STOPLEVEL);


if(TrailingStop<minstop) TrailingStop=minstop;

SL=NormalizeDouble(Bid+Point*TrailingStop,Digits)*tsm;


Alert("ticket ",OrderSymbol()," Symbol ",Symb);
Alert(ticket," SL-",SL," OSL ",OrderStopLoss());
Alert("price ",OrderOpenPrice());
Alert("TP ",TP);
Alert("min stop ",MarketInfo(Symb,MODE_STOPLEVEL));

Mod=OrderModify(ticket,OrderOpenPrice(),SL,TP,0,CLR_NONE);


err=GetLastError();
Alert("err ",err);

Alert("mod ",Mod);

Alert(ticket," sell SL-",SL," OSL ",OrderStopLoss());
Alert("type ",OrderType()," Sell Order ",ticket," - Trailing stop modified-",OrderStopLoss());
}

Reason: