-
(OrderSelect(orderID1,SELECT_BY_TICKET) == true)
If you select by ticket, you must verify that the order is still open and not still pending.
-
EAs must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover?
Use a OrderSelect / Position select loop to recover, or persistent storage (GV+flush or files) of ticket numbers required.
-
orderID2 = OrderSend(NULL, 0, loteSize, entryPrice, 10, stopLoss, takeProfit, "Long open, mFrac complex");
Be careful with NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum (2020)
-
If you select by ticket, you must verify that the order is still open and not still pending.
-
EAs must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover?
Use a OrderSelect / Position select loop to recover, or persistent storage (GV+flush or files) of ticket numbers required.
-
Be careful with NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum (2020)
So I wanna to tell u thanks!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey! Im having problems with the ModifyOrder();
I have my strategy that sends Shorts and Longs of 2 kinds each, and when its come to a certain point, I want to modify the SL to the Open price. I think the problems comes when I call the trade open in the next way.
The EA is taking the parameters of the last trade instead of the current one (I checked it calling the SL and Open trade price) and I don’t t know why, and obviously gave me error and is not modifying the order.
Here is my code...