Close all Open Positions when Remove EA

 

Hi! I'm new on mql5.


I had been trying to close all positions when you remove the EA manually using the OnDeInit() function, but when is called, it says 'Trading is Disabled' ...


I don't know if by doing it in OnDeInit() is the right way, or if I'm doing something wrong.


Can somebody help me understand what I'm doing wrong?, or if there is another way to do this.


Thanks in advance... 

Reason: