please edit your post -
--------------------------
When you post code please use the CODE button (Alt-S)!
-
Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
Messages Editor
Forum rules and recommendations - General - MQL5 programming forum (2023) -
You know what the problem is, now read the documentation and learn MT5. Your posted code is mostly MT4.
-
There is no need to create pending orders in code.
-
The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)
Don't worry about it unless you're scalping M1 or trading news.
-
Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.
-
//+------------------------------------------------------------------+ //| Delete all pending orders at the specified time | //+------------------------------------------------------------------+ void DeletePendingOrders() { for (int i = OrdersTotal() - 1; i >= 0; i--) { if (OrderSelect(i,SELECT_BY_POS)) { int orderType = (int)OrderGetInteger(ORDER_TYPE); if (orderType == ORDER_TYPE_BUY_STOP || orderType == ORDER_TYPE_SELL_STOP) { ulong ticket = OrderGetTicket(); if (!trade.OrderDelete(ticket)) { Print("Error deleting pending order: ", GetLastError()); } else { Print("Pending order deleted: ", ticket); } } } } } //+------------------------------------------------------------------+
please edit your post -
--------------------------
When you post code please use the CODE button (Alt-S)!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Error: