Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Parameter error

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

    Strategy Parameter error

    Hi,

    NinjaTrader displayed the "I had a problem" message (why isn't important) and I shut it down. However, now it refuses to recognize the correct parameters for the strategy when you add a new strategy via the Strategies tab.

    If you add the strategy via the chart, everything is correct. There are a couple of strategies that appear correct but most now just give the same set of parameters regardless.

    If this is a known problem, please give me a fix, if not, going through the process of sending everything in will likely take longer than just rebooting, etc.

    And of course, I have stopped and restarted NinjaTrader several times to no avail.

    Thanks in advance.

    Scott

    #2
    Hi Scott,

    If it shutdown improperly, there may corruption in the xml file managing your strategy defaults. Please shutdown NinjaTrader. Then go to:
    My Documents\NinjaTrader 7\templates\strategy

    Delete xml files matching the strategy you're having trouble with.

    If this isn't it, I would check log tab of control center for any error messages processing Initialize() method.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ryan, thanks for the quick reply. That directory is empty. The source is intact (and of course backed up). Can I just delete the strategy and then recreate it?

      I do have an error in the log, I was trying to dynamically add a second instrument which had been working and then quit. I have since found posts in the forum indicating that isn't supported.

      Thanks again
      Scott

      Comment


        #4
        It's likely the error with the other script that is causing issues. Initialize() is called for all scripts and if there is an error noted it can affect other strategies. First step is resolve the error there by hard coding the series, and see if it resolve the issue with the other strategy.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Ryan, I do have another error and if you know a way around it, that would be great.

          I was trying to dynamically add bars objects which I am now just adding every period the user might want to get around that.

          However, can I put an indicator on a second bar object? I tried this in initialize

          Add(TrendDirection(BarsArray[1], trendLookbackBars));

          but that decidedly doesn't work. I get the message about not being able to access the bars object in Initialize.

          Any suggestions will be appreciated.

          Best Regards,
          Scott

          Comment


            #6
            Right, you won't be able to access BarsArray in Initialize() method but it is possible to add multiseries indicators to your strategy.

            You can add an additional series to the Indicator, base its calculations off the secondary series, and then add this indicator to your strategy.

            One caveat to this approach is that the session template for the indicator will use what is defined in the instrument manager, rather than the session template applied in the strategy.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Ryan, thanks for the caveat but since I always use the same session template I think that won't be an issue.

              Just like you can expose multiple plot values, I assume I can have public properties that will expose all the various indicator values needed. Essentially I am shifting all the calculation out of the strategy and down to the indicator and then exposing the values there to use back in the strategy.

              You have devised a fiendishly clever plan; thanks.

              Comment


                #8
                Yes, exactly. If you base the indicator plots on the secondary series, then the strategy will use those values. You can also expose other types of values from the indicator as you mention, following with this sample:
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks Ryan

                  Comment


                    #10
                    One more question - are there any performance implications of calling an indicator once with the primary bar series and then again with a secondary bar series?

                    Comment


                      #11
                      I guess it is never just one more question with me.

                      I found this code that Bertrand wrote and posted a while back. Did this stop working with NT 7 because it appears to do what you said I couldn't (and I actually couldn't) do.

                      #region Variables
                      // Wizard generated variables
                      privateint sMAperiod = 10; // Default setting for SMAperiod
                      privateint dataSeries1 = 150; // Default setting for DataSeries1
                      privateint dataSeries2 = 450; // Default setting for DataSeries2
                      // User defined variables (add any user defined variables below)
                      #endregion
                      ///<summary>
                      /// This method is used to configure the indicator and is called once before any bar data is loaded.
                      ///</summary>
                      protectedoverridevoid Initialize()
                      {
                      // ADD SECOND TIMEFRAME
                      Add(PeriodType.Tick, dataSeries1);
                      // ADD THIRD TIMEFRAME
                      Add(PeriodType.Tick, dataSeries2);

                      Add(
                      new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                      Add(
                      new Plot(Color.FromKnownColor(KnownColor.LightSkyBlue) , PlotStyle.Line, "Plot1"));
                      Add(
                      new Plot(Color.FromKnownColor(KnownColor.Ivory), PlotStyle.Line, "Plot2"));
                      CalculateOnBarClose =
                      true;
                      Overlay =
                      true;
                      }

                      Comment


                        #12
                        What you're doing there is using the hard coded variable for adding the series. Dynamically adding series is not supported although some people have found implementations that work. There's no guarantee on timing of Initilize compared to setting a public input so we always suggest that series are hard coded.
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #13
                          Ryan,

                          Thanks, that makes the difference clear. I was processing the user input which could be resolved after I was trying to use it; gotcha.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          630 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          364 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          105 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          566 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          568 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X