How to close open trades on Expert Removal?

To add comments, please log in or register
cs0amc
108
cs0amc  

Hi,

I have been trying to close any open trades from the DeInit function but it is returning that trading is already stopped. I  also tried to override ExpertRemove function but it says it is a system function. Anyone know how I can do this?

Thanks

cs

 

**EDIT ** This is for MT5

Alain Verleyen
39529
Alain Verleyen  
cs0amc:

Hi,

I have been trying to close any open trades from the DeInit function but it is returning that trading is already stopped. I  also tried to override ExpertRemove function but it says it is a system function. Anyone know how I can do this?

Thanks

cs

 

**EDIT ** This is for MT5

What's the reason of the removal ?
cs0amc
108
cs0amc  
Alain Verleyen:
What's the reason of th
Alain Verleyen:
What's the reason of the removal ?
Simply to ensure no trades are left open when an expert advisor is removed from a chart. This is helpful for live testing and also if dealing with multiple EA's, it removes the chance of any trades being left open.
Alain Verleyen
39529
Alain Verleyen  
cs0amc:

Hi,

I have been trying to close any open trades from the DeInit function but it is returning that trading is already stopped. I  also tried to override ExpertRemove function but it says it is a system function. Anyone know how I can do this?

Thanks

cs

 

**EDIT ** This is for MT5

You have to use OrderSend() or OrderSendAsync(), not CTrade.
To add comments, please log in or register