Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddDataSeries doesn't work with Strategy Analyzer Optimization

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

    AddDataSeries doesn't work with Strategy Analyzer Optimization

    Hello,
    I'm using NT 8.0.9.0 64-bit. When I try to test multi-timeframe strategy in Strategy Analyzer with Backtest type Optimization, it fails with error:
    Strategy '<name>': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
    Testing those strategies with Strategy Analyzer Backtest type Standard, it works fine.
    Ex. Take SampleMACrossOver and add second timeframe:
    Code:
    else if (State == State.Configure)
    {
      AddDataSeries(Instrument.FullName, BarsPeriodType.Tick, 1);
     }
    With that code, strategy can't pass State.Configure, when run in SA with Optimization.
    Why Strategy Analyzer can't optimize strategy with second timeframe?

    #2
    Hello InteRadek,

    Thanks for opening the thread.

    This is a known limitation involving dynamically added Data Series which is not fully supported by NinjaScripts.

    From the help guide:
    Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.
    However in this case, the Instrument is returning as a null object when it is accessed in State.Configure for the optimization.

    We are tracking interest to fully support dynamically added data series with the feature request ticket ID SFT-882. I'll submit a vote on your behalf.

    Upon implementation, this ID will be listed in the Release Notes page of the version of NinjaTrader that includes it. You can find the Release Notes here: https://ninjatrader.com/support/help...ease_notes.htm

    Feature requests are fulfilled based on our development team's schedule and priorities and we cannot provide a time frame for it to become available.

    If there is anything else I can do in the meantime, please let me know.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you for the informations. Hopefully dynamically added data series will be available soon.
      What is a good way to check if a strategy is running in Optimization mode?
      Code:
      else if (State == State.Configure)
      {
        if (?optimization?)
          AddDataSeries("instrument name", BarsPeriodType.Tick, 1);
        else
          AddDataSeries(Instrument.FullName, BarsPeriodType.Tick, 1);
      }
      Last edited by InteRadek; 10-09-2017, 12:24 AM.

      Comment


        #4
        Hello InteRadek,

        This is not documented and we could not guarantee the functionality will remain unchanged and will always work. I was able to find some direction you could follow to detect this, however.

        Code:
        if (State == State.Configure)
        {
        	if (Category == Category.Backtest)
        		Print("Strategy is running a regular backtest ");
        	else if (Category == Category.Optimize)
        		Print("Strategy is running an optimization ");
        	else if (Category == Category.WalkForward)
        		Print("Strategy is running walk forward optimization");
        	else if (Category == Category.MultiObjective)
        		Print("Strategy is running a multi objective optimization ");
        	else if (Category == Category.NinjaScript)
        		Print("Strategy is running on an account from a chart/strategies tab ");
        }
        See post #2 here: https://ninjatrader.com/support/foru...ad.php?t=78992

        Please let me know if this does not resolve your inquiry.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by vantojo, Today, 01:39 PM
        0 responses
        16 views
        0 likes
        Last Post vantojo
        by vantojo
         
        Started by Rubens_2020, Today, 01:48 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by kempotrader, Today, 01:34 PM
        1 response
        23 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by bc24fl, Today, 01:50 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by bosajin, 01-21-2021, 09:15 AM
        7 responses
        61 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Working...
        X