I am overriding the OnTermination() method of my strategy to write to a text file.
When running the the market analyser for multiple instruments my understanding is that it is creating a new thread for each strategy. This is fine and I have put a lock around the OnTermination() method, however i need a way to determine if the Strategy is the first to be processed for the backtest run.
I need to write to the text file with the conditions:
(i) If it is the first strategy to be complete in the backtest then FileMode.Create
(ii) If it is NOT the first strategy to be processed in the backtest run then FileMode.Append
I tried to make a static bool firstRun = true which is set to false in OnTermination but this variable is never reset after running the first backtest.
I hope this makes sense
Comment