I am completely stumped and would welcome any ideas. The below code is part of a larger and fairly complex logical sequence, but because of the printing I can see that the logical structure is functioning properly. However the OrderModify function is generating error 3. Is it not correct to use zeroes for values you don't want changed? These are pending orders (OP_SELLSTOP) and in this example I don't want to change the entry price (the 0 before "shortSL) and the EA doesn't use take profit values.
In effect the below if-else sequence is choosing between a predetermined stop price ("shortSL") or a freeze value ("upperFreeze" based on MarketInfo(_Symbol,MODE_STOPLEVEL)).
Any ideas would be very much appreciated.
Step 1: Find the significance of the error code: Trade Server Return Codes
In this case Error 3, ERR_INVALID_TRADE_PARAMETERS, signifies "Invalid trade parameters".
Step 2: Read-up on the function in question: OrderModify()
In this case, we can see that for pending orders you have to supply an Opening price (not 0). If you do not wish to change it then use the original price with OrderOpenPrice(). The same goes for the stops — if you don't plan to change or disable them, then use the original prices with OrderStopLoss() and OrderTakeProfit(). Do the same for expiration as well. See the example code in the documentation.
Other observations:
It is not possible from your code to see if you are properly selecting the order before executing the modification. So show that part too if the issue is not resolved with these suggestions. Also look into both the Stops Level and Freeze Level. They are not the same thing. Requirements and Limitations in Making Trades

- docs.mql4.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am completely stumped and would welcome any ideas. The below code is part of a larger and fairly complex logical sequence, but because of the printing I can see that the logical structure is functioning properly. However the OrderModify function is generating error 3. Is it not correct to use zeroes for values you don't want changed? These are pending orders (OP_SELLSTOP) and in this example I don't want to change the entry price (the 0 before "shortSL) and the EA doesn't use take profit values.
In effect the below if-else sequence is choosing between a predetermined stop price ("shortSL") or a freeze value ("upperFreeze" based on MarketInfo(_Symbol,MODE_STOPLEVEL)).
Any ideas would be very much appreciated.
Below is an example where I am trying to change the entry price while leaving the stop level alone, but it is also generating error 3. In all cases these are pending orders - either OP_SELLSTOP in these examples or in other places OP_BUYSTOP.