Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Input parameters reset in custom Series

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

    Input parameters reset in custom Series

    Hello
    In my strategy, I have custom Series which is instantiated for each optimization run in State.Dataloaded. However, in that custom Series I also have input parameters to be optimized on each run (these parameters are created in New Strategy dialog). Do I need to explicitly reset those parameters as well?

    Thank you very much.

    #2
    Hello thebigarch,

    Thank you for your note.

    You would not have to reset these variables if you were setting IsInstantiatedOnEachOptimizationIteration to true, so that a new strategy is recreated on each optimization.

    The following link provides additional detail,


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Alan. But I'm still not sure I got it right.

      I want to gain performance benefit when backtesting, so I would need to set IsInstantiatedOnEachOptimizationIteration to false.

      The 2nd example in the link you sent me covers only the fields that need to be reset such as myDouble, myBool, myDateTime, mySeries<double>, and so on... but doesn't mention resetting the input parameters of the strategy.

      I've found another example in the SampleMACrossOver
      Code:
      else if (State == State.DataLoaded)
                  {
                      smaFast = SMA(Fast);
                      smaSlow = SMA(Slow);
      
                      smaFast.Plots[0].Brush = Brushes.Goldenrod;
                      smaSlow.Plots[0].Brush = Brushes.SeaGreen;
      
                      AddChartIndicator(smaFast);
                      AddChartIndicator(smaSlow);
                  }
      In this example, the input parameters (Fast, Slow) are explicitly reset in State.DataLoaded. But then again they are not in the custom Series

      Here is my situation : I created a custom Series<double> which holds calculation from various indicators and those indicators contain input parameters to be optimized in each optimization iteration like lookback period of EMA and so on.

      Here is the sample code

      Code:
      else if (State == State.DataLoaded)
      {
          customSeries = new Series<double>(this);
      }
      protected override void OnBarUpdate()
      {
          customSeries[0] = Close[0] + SMA(Fast)[0] - SMA(slow)[0]
      
      if (Close[[COLOR=#FF9752]0[/COLOR]]>Open[[COLOR=#FF9752]0[/COLOR]]&&CrossAbove(Close,customSeries),[COLOR=#FF9752]5[/COLOR]))
                      EnterLong();
      }
      1. In State.DataLoaded, I have my customSeries<double> reset
      2. In OnBarupdate I assign customSeries to some calculation with some input parameters (Fast, Slow).

      To be specific I want to know :

      Even though I've already reset the customSeries that uses these input paramters, Do I still need to explicitly reset the input parameters (Fast, Slow) inside that customSeries?

      I'm a newbie and I hope I made my examples and question clear, if not please pardon me and I'll try my best again.

      Thank you.
      Last edited by thebigarch; 04-13-2018, 10:07 AM.

      Comment


        #4
        Hello thebigarch,

        Thanks for the reply.

        You do not need to reset the parameters from which the series reads from as long as you set up the inputs in the strategy itself. If Fast and Slow are inputs of the strategy that you then use in this line:

        Code:
        customSeries[0] = Close[0] + SMA(Fast)[0] - SMA(slow)[0]
        and you optimize them on some domain, then the optimizer will use the new values every time there is a new optimization since SMA(x) is a one-off instantiation of the SMA indicator.

        Please let us know if you have any questions.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by martin70, 03-24-2023, 04:58 AM
        15 responses
        114 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by The_Sec, Today, 02:29 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by jeronymite, 04-12-2024, 04:26 PM
        2 responses
        31 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by Mindset, 05-06-2023, 09:03 PM
        10 responses
        265 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by michi08, 10-05-2018, 09:31 AM
        5 responses
        743 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X