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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    65 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    139 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X