Hi all,
hope you are ok.
i need your help to help me fix the OrderModify error 1 when using trailing stop.
i tried to compare new SL and old one with no succuss , your help will be so much appreciated. thanks
here is my code :
double tStopLoss = NormalizeDouble(OrderStopLoss(), Digits);
if(OrderType()==OP_BUY){
if(Ask> NormalizeDouble(OrderOpenPrice()+TrailingStart* myPoint,Digits) && tStopLoss < NormalizeDouble(Bid-(TrailingStop+TrailingStep)*myPoint,Digits)){
tStopLoss = NormalizeDouble(Bid-TrailingStop*myPoint,Digits);
OrderModify(OrderTicket(),OrderOpenPrice(),tStopLoss,OrderTakeProfit(),0,Blue);
}}
double sl = NormalizeDouble(OrderStopLoss(), Digits);
if (OrderType()==OP_SELL) {
if (Bid < NormalizeDouble(OrderOpenPrice()-TrailingStart*myPoint,Digits)&& (sl >(NormalizeDouble(Ask+(TrailingStop+TrailingStep)*myPoint,Digits)))|| (OrderStopLoss()==0)){
sl = NormalizeDouble(Ask+TrailingStop*myPoint,Digits);
OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,Red);
}}
Order modify error means that the parameters you tried to apply did not make any change to the actual order
Simply check if the stop loss and/or take profit price will be changed or not at all compared to the existing stop loss and/or take profit of the selected order before trying to change the order (otherwise you shall get "error" 1 when those are exactly the same as they are already)
Hi all,
hope you are ok.
i need your help to help me fix the OrderModify error 1 when using trailing stop.
i tried to compare new SL and old one with no succuss , your help will be so much appreciated. thanks
here is my code :
double tStopLoss = NormalizeDouble(OrderStopLoss(), Digits);
if(OrderType()==OP_BUY){
if(Ask> NormalizeDouble(OrderOpenPrice()+TrailingStart* myPoint,Digits) && tStopLoss < NormalizeDouble(Bid-(TrailingStop+TrailingStep)*myPoint,Digits)){
tStopLoss = NormalizeDouble(Bid-TrailingStop*myPoint,Digits);
OrderModify(OrderTicket(),OrderOpenPrice(),tStopLoss,OrderTakeProfit(),0,Blue);
}}
double sl = NormalizeDouble(OrderStopLoss(), Digits);
if (OrderType()==OP_SELL) {
if (Bid < NormalizeDouble(OrderOpenPrice()-TrailingStart*myPoint,Digits)&& (sl >(NormalizeDouble(Ask+(TrailingStop+TrailingStep)*myPoint,Digits)))|| (OrderStopLoss()==0)){
sl = NormalizeDouble(Ask+TrailingStop*myPoint,Digits);
OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,Red);
}}