-
Just to be precise, the documentation says: The OnDeinit() function run is restricted to 2.5 seconds. You don't have time to close/delete them.
-
Do you really want to remove them on just a chart timeframe change?
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.
-
the correct way to delete pending orders when expert is removed.
void OnDeinit( const int reason ) { //--- // delete pending orders trade.SetAsyncMode(true); for (int i = OrdersTotal() - 1; i >= 0; i--) if (OrderGetTicket(i) && (OrderGetInteger(ORDER_MAGIC) == inpMagicEA) && (OrderGetString(ORDER_SYMBOL) == _Symbol)) trade.OrderDelete(OrderGetInteger(ORDER_TICKET)); }
- 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, I am having troubles deleting pending orders when I release the EA from chart. OnDeInit() I use the following code
Does anyone have know why this wouldnt work, and it would be much appreciated if someone could share the correct way to delete pending orders when expert is removed.