Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimizer relation to State.Configure

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

    Optimizer relation to State.Configure

    Hello,

    I need to write a strategy that is optimized by the StartegyAnalyzer Optimization. I also want to optimize my strategy by a time-frame.
    As I know AddDataSeries is best to be invoked in State.Configure.

    My questuons are:

    1. Is State.Configure invoked on every Optimizer iteration?
    2. If it is not, how can I load different data series on every Optimization iteration?
    3. Is there a relation between IsInstantiatedOnEachOptimizationIteration property and the State.Configure?

    Any other advices on how to invoke AddDataSeries on every optimization iteration are welcome.

    Best wishes.


    #2
    Hello nrgful,

    Only the primary series interval can be optimized.
    "Optimize data series" - https://ninjatrader.com/support/help...tionProperties

    NinjaTrader does not support using variables in AddDataSeries() that can change dynamically as this will break optimizations.

    "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."
    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.



    "As I know AddDataSeries is best to be invoked in State.Configure."

    AddDataSeries() does need to be called from State.Configure.


    "1. Is State.Configure invoked on every Optimizer iteration?"

    When IsInstantiatedOnEachOptimizationIteration is false, OnStateChange() will update with State.Configure for each iteration. When IsInstantiatedOnEachOptimizationIteration is true, OnStateChange() will not update with State.Configure for each iteration.


    "2. If it is not, how can I load different data series on every Optimization iteration?"

    You are only able to optimize the primary series with the 'Optimize data series' option.


    "3. Is there a relation between IsInstantiatedOnEachOptimizationIteration property and the State.Configure?"

    When IsInstantiatedOnEachOptimizationIteration is false, OnStateChange() will update with State.Configure for each iteration. When IsInstantiatedOnEachOptimizationIteration is true, OnStateChange() will not update with State.Configure for each iteration.


    "Any other advices on how to invoke AddDataSeries on every optimization iteration are welcome."

    Unfortunately, this is not supported.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you very much for your detailed answer.

      And what about an Indicator parameters?
      I have custom indicator written by myself. I also want to dinamically update indicator parameters during each optimizer iteration.

      Is it possible for my indicator parameters to be updated during State == State.DataLoaded or some other state?

      Best wishes

      Comment


        #4
        Hello nrgful,

        Yes, indicator methods can be called with different parameters.

        Note, within indicators any calls to AddDataSeries() cannot use variables.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          @NinjaTrader_ChelseaB​ Is it appropriate to set the new indicator parameters on the new optimizer iteration in State.DataLoaded ?

          Comment


            #6
            Hello nrgful,

            Yes, indicators can be called from State.DataLoaded with any new parameters.
            Chelsea B.NinjaTrader Customer Service

            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