Hi
Can anyone see any reason why the above OrderModify is generating an error zero? The Order Modify is trying to move the stop loss of the open position, and it's definitely not doing it. I just can't see why as error 0 code is not that helpful when I have looked it up in the reference manual
Thanks
Show your code so people may be able to help you.
Do you check that the new SL is different to the old SL?
- Did you bother to look up error 0?
- Check your return codes for errors, and report them including GLE/LE.
Don't look at
GLE/LE unless
you have an error. Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
if(Bid>OrderOpenPrice()+x1*(OrderOpenPrice()-OrderStopLoss())) LongA= OrderModify(…); if(!LongA) Print("Error modifying LongStopA", GetLastError()); else Print("LongStopA rolled to ", OrderStopLoss());
Now that you have posted your code, remember I said "don't look at LE unless you have an error"
Your code looks at it even if you don't call OrderModify.
Hi
Can anyone see any reason why the above OrderModify is generating an error zero? The Order Modify is trying to move the stop loss of the open position, and it's definitely not doing it. I just can't see why as error 0 code is not that helpful when I have looked it up in the reference manual
Apologies, I thought I'd included it. x1= 0.5 at the moment, I've tried a couple of different numbers though.
Thanks
void rolLongStopA() { for(int b=OrdersTotal()-1; b>=0; b--) { bool LongA; if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber()==Magic) if(OrderType()==OP_BUY) if(Bid>OrderOpenPrice()+x1*(OrderOpenPrice()-OrderStopLoss())) { LongA= OrderModify(OrderTicket(),ND(OrderOpenPrice()),ND(OrderStopLoss()+x1*(OrderOpenPrice()-OrderStopLoss())),ND(OrderTakeProfit()),0,clrPurple); if(!LongA) Print("Error modifying LongStopA", GetLastError()); else Print("LongStopA rolled to ", OrderStopLoss()); rolLongA=false; rolLongB=true; rolShortA=false; rolShortB=false; } } }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
Can anyone see any reason why the above OrderModify is generating an error zero? The Order Modify is trying to move the stop loss of the open position, and it's definitely not doing it. I just can't see why as error 0 code is not that helpful when I have looked it up in the reference manual
Apologies, I thought I'd included it. x1= 0.5 at the moment, I've tried a couple of different numbers though.
Thanks