Strategy tester: Clicking the stop button

 

I'm wondering what happens eventwise when we stop the strategy tester. Is there no event triggered when this happens?

Let me explain: My EA opens and writes lines to a file. The file is closed at the OnDeinit() event. All is fine when I run the EA till the end, but if I stop it by clicking the stop button, the file remains open and i have to restart the terminal in order it closes the file.

Any clues? Any OnAbruptlyStopped() event?

 

Hi Frederic,

I need to know this, too.

Did you find a solution?

Best regards

Jorg

 
I looked for this, too, but couldn't find an event that triggers on "Stop" of the Strategy Tester.  If someone figures out how to have code fire on the "Stop" of the Strategy Tester, that would be great.  Without that, the OnDeinit() code will run once the Strategy Tester has processed the entire date range you specified in the settings for your run.
 

You can try using the function ExpertRemove();

The function stops an Expert Advisor and unloads it from a chart.

 ExpertRemove();
MQL5 Reference - How to use algorithmic/automated trading language for MetaTrader 5
MQL5 Reference - How to use algorithmic/automated trading language for MetaTrader 5
  • www.mql5.com
MQL5 Reference - How to use algorithmic/automated trading language for MetaTrader 5