I have a strategy that can run using the Back test type: 'Backtest', but when I try to 'Optimization' it comes with an error. The one we probably hate most as it really does not say what....
Strategy 'ADSNTC2': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
I have compiled it with debug mode on, also using Visual Studio 2022, but what I cannot understand is why it works under Backtest (both from the chart or analyzer, but cannot optimize (does not matter what parameter, same result)
Checking the log files does not make me wiser as it just says the same thing, but not which line of the code. (I did read the article from NT to please always compile with debug mode as well)
Can I run the optimizer using the debugger from Visual Studio? Is there perhaps a Try/Catch/Error trick I can use? (I know this is dirty)
Any help, hints, workarounds are appreciated.
Thanks -- Ronald

Comment