Hello everyone,
I get an error 130 when I am doing an OrderModify.
The code is:
The vars has values:
The print output is:
I don't know where canbe the error...I have checked everything and no sense!!
Can you help me please?
Thank you in advance!
Are you trying to set SL at same value as TP ?
_res = OrderModify(OrderTicket(), OrderOpenPrice(), 9598.8, tp, 0);
2015.01.08 08:19:43.302 #FDXH5,M1: SetSLTP: OrderModify(#38220494 @9646.0) - SL(0.0): 9708.8 TP(0.0):9598.8
Yes, sorry. One of my test was wrong and I was just putting here the wrong copy/paste.
The code that does not work is:
void SetSLTP(){ double sl, tp; for (int i = OrdersTotal() - 1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && (OrderType() == OP_BUY || OrderType() == OP_SELL)) if (OrderStopLoss() == 0 && OrderTakeProfit() == 0) { sl = 0; tp = 0; if (OrderType() == OP_BUY){ tp = profitUp + PipsToPoints(10); sl = slSecurityDown; } else if(OrderType() == OP_SELL){ tp = profitDown - PipsToPoints(10); sl = slSecurityUp; } if (sl != 0 || tp != 0){ _res = OrderModify(OrderTicket(), OrderOpenPrice(), sl, tp, 0); int err = GetLastError(); if(!_res && err > 0){ Print(MarketInfo(Symbol(),MODE_STOPLEVEL)); Print("SetSLTP: OrderModify(#"+IntegerToString(OrderTicket())+" @"+DoubleToStr(OrderOpenPrice(), _Digits) +") - SL("+DoubleToStr(OrderStopLoss(), _Digits)+"): " + DoubleToStr(sl, _Digits) + " TP("+DoubleToStr(OrderStopLoss(), _Digits)+"):" + DoubleToStr(tp, _Digits)); Print("Error in OrderModify. Error code=",err, " -> ", ErrorDescription(err)); Print(""); } } } }
And the result it's the same as the first post. I can not understand why. Can you help me please?
Thank you in advance
Yes, sorry. One of my test was wrong and I was just putting here the wrong copy/paste.
The code that does not work is:
And the result it's the same as the first post. I can not understand why. Can you help me please?
Thank you in advance
Hello,
Try this :
_res = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(sl,_Digits), NormalizeDouble(tp,_Digits), 0);
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone,
I get an error 130 when I am doing an OrderModify.
The code is:
The vars has values:
The print output is:
I don't know where canbe the error...I have checked everything and no sense!!
Can you help me please?
Thank you in advance!