Hi,
I have an EA which will close all open orders and positions in the OnDeinit function.
This works fine if if I change the timeframe of the chart the EA is attached to.
But if I remove the EA from the chart the OnDeinit function will be called; but cannot close the open orders and positions,
the error message is
Is this intended?
If yes, how I can close open orders after having finished the EA? Separate script?
Matthias
Add a button on your chart "Close and exit", when clicked close your orders and remove the EA from the chart.
Using OnDeinit() is very bad practice.
Add a button on your chart "Close and exit", when clicked close your orders and remove the EA from the chart.
Using OnDeinit() is very bad practice.
Fast Navigation - User Interface - MetaTrader 4 Help (Hot keys)
Hot Keys - For Advanced Users - MetaTrader 5 Help
dont use deinit for trade exit,
use ontick instead
Because I have seen that EA can already do this function, please refer to the following video
My MT5 Version= 5.00 build 3446
-
No one will, because no one can. Read the thread again.
-
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 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.)
-
No one will, because no one can. Read the thread again.
-
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 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.)
Thanks for reply and notification
Because this function is one of the functions requested by users
So I came to ask
I have searched for related topics, and currently MT5 cannot perform the action of deleting pending orders after OnDeinit().
So I'm really curious how the EA in the movie did it
Possibilities ...
- It may issue asynchronous order deletes without actually checking if they are carried out.
- It may send a signal to another EA or Service that is running, so that it carries out the procedure on behalf of the EA that is being terminated.
- The video may be 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,
I have an EA which will close all open orders and positions in the OnDeinit function.
This works fine if if I change the timeframe of the chart the EA is attached to.
But if I remove the EA from the chart the OnDeinit function will be called; but cannot close the open orders and positions,
the error message is
Is this intended?
If yes, how I can close open orders after having finished the EA? Separate script?
Matthias