How to open and write a file (CSV/TXT) in a history-debug runmode?

 

i have an EA and i use FileOpen in OnInit() to get a valid handle. and use FileWrite in OnTick() to write some features , after i ran this EA in history-debug mode(CTRL+F5), in the end, there is no file created!

but i ran the same code in realtime mode (F5), the file eventually created successfully and has content inside.

My purpose now is to log some statistics to a file during  history-debug process (to generate the features table used to training machine learning model), how should i modify my code? Thanks!

 

and same result using sqlite(DatabaseOpen).

So, besides database and file system, is there any way to collect data in every Ontick step and generate a summary file or something  through running an EA in history run mode(Strategy Tester)? 

 
Place, read and write the files in the Common folder: https://www.mql5.com/en/docs/runtime/testing#common_folder
Documentation on MQL5: MQL5 programs / Testing Trading Strategies
Documentation on MQL5: MQL5 programs / Testing Trading Strategies
  • www.mql5.com
Testing Trading Strategies - MQL5 programs - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Carl Schreiber #:
Place, read and write the files in the Common folder: https://www.mql5.com/en/docs/runtime/testing#common_folder
Thank you. perfectly solved!
Reason: