Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

In the Strategy Analyzer it works in backtest but not in optimizer...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    In the Strategy Analyzer it works in backtest but not in optimizer...

    I have read now many articles about the debugging of NT, but this one I could not find.

    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

    #2
    OK, so after digging I found out it was a drawing object (totally not needed for a back test), once I disabled it, it was running.

    How I found out was really using the Visual Studio debugger.

    First, I made sure the strategy was compiled with Debug mode on, then attached the Visual Studio and started stepping through the lines. Without this it would have almost impossible to find out. At least the debugger tells you where and what line. I wish this was already in the error logs. But at least I found a solution.

    (And yes, most of the time, errors like these are the ones we do not look for when debugging

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    87 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    132 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    65 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    118 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X