sheriffonline:
Yes. Fixed already. Thanks WHRoeder.
Hi sheriffonline, can you share your solution please?
Yes. Fixed already. Thanks WHRoeder.
pije76: Hi sheriffonline, can you share your solution please?
| When in doubt, think.double SL = ...; double TP = ...; if(MathAbs(OrderStopLoss() - SL) > _Point // Something is || MathAbs(OrderTakeProfit() - TP) > _Point){ // different. bool ret = OrderModify(... : |
whroeder1:
When in doubt, think. |
I have a similar situation with this code:
void SellOrderModify1() { for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == SellID) { double price= OrderOpenPrice(); if (Bid< QTakeprofit_1)price=QTakeprofit_2;{ bool ret = OrderModify(OrderTicket(), OrderOpenPrice(),price, OrderTakeProfit(), 0, White); if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError()));} } } }
QTakeProfit is the pair quote value, like 1.30220
If the Bid is bigger than QTakeProfit_1, (Something changed) and
will modify the order to set a new OrderStopLoss() = QTakeProfit_2.
But never get rid of the same error-
OrderModify() error - no error, trade conditions not changed
Maybe I missing something. Thank you in advance for the correction.
Sherif Hasan:
I change stoploss as breakeven once the price moves +20pips
why should i get the error while backtesting?
for (int i=OrdersTotal()-1; i >= 0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { if(MarketInfo(Symbol(),MODE_BID)<OrderOpenPrice()-200*Point) { //double SL = NormalizeDouble(OrderOpenPrice(), NDigits); //double TP = NormalizeDouble(0, NDigits); bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(),OrderTakeProfit(), 0, White); if (GetLastError()>0) Print("OrderModify() error - ", ErrorDescription(GetLastError())); } } }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I change stoploss as breakeven once the price moves +20pips
why should i get the error while backtesting?