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

Parameter Error

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

    Parameter Error

    The following code causes the attached error when I load the strategy on a chart. However, the stategy seems to work fine.
    When I load it on the strategy analyzer, no error occurs.

    I have tried to enter parameters with objHighBarsAgoNumber (which is what the error seem to be about) but I can't get it to compile. The strategy is doing what it should. I would like some insight on what the error is happening.


    objHighBarsAgoNumber.Set (Highs[
    0][1]);
    //
    HighBarsAgoNumber = (HighestBar(objHighBarsAgoNumber,30)+1);

    Thank you,
    Duke




    Attached Files

    #2
    Can you post the code you're using in #region Properties?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Sure thing, Matthew---
      Thanks for checking this out ..

      #region Variables
      // Wizard generated variables
      private int myInput0 = 1; // Default setting for MyInput0
      // User defined variables (add any user defined variables below)
      double SMACurrent;
      double SMAPast;
      double DiffMACDCurrent;
      double DiffMACDPast;
      double DiffMACDCalc;
      double HighValuePast;
      double HighValueCurrent;
      double LowValueCurrent;
      double LowValuePast;
      int HighBarsAgoNumber;
      int LowBarsAgoNumber;
      public DataSeries objHighBarsAgoNumber;
      public DataSeries objLowBarsAgoNumber;
      string DateTime;

      Comment


        #4
        Sorry Duke - I meant the #region Properties section which is below OnBarUpdate()

        Although - do you mean to expose this data series as public? You might just wanna try changing it to private DataSeries in your Variables section

        Pleaes have a look at our DataSeries class of our Help Guide for information on how to declare and set a data series:

        MatthewNinjaTrader Product Management

        Comment


          #5
          Sorry, Matthew.. my fault,
          #region Properties
          [Description("")]
          [GridCategory("Parameters")]
          public int MyInput0
          {
          get { return myInput0; }
          set { myInput0 = Math.Max(1, value); }
          }

          #endregion

          Comment


            #6
            Thanks - in Variables can you please set thees data series as private:

            Code:
            private DataSeries objHighBarsAgoNumber;
            private DataSeries objLowBarsAgoNumber;
            MatthewNinjaTrader Product Management

            Comment


              #7
              Matthew,
              That fixed it. Can you explain the problem?
              Thank you very much..
              Duke

              Comment


                #8
                A public variable needs to be serialized which can then be used as a public property.

                Since you're not exposing this data series outside of this script, there is no need to serialize this data series and you can simply declare it as private.

                If you wanted to expose this data series to another indicator or strategy, you can link the private DataSeries to a Public DataSeries which would then be serialized in the #region Properties section.

                If you'd like to learn more about this, please see our Help Guide article on Exposing indicator values which are not plots:

                MatthewNinjaTrader Product Management

                Comment


                  #9
                  Thank you Matthew..

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by mattbsea, Today, 05:44 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post mattbsea  
                  Started by RideMe, 04-07-2024, 04:54 PM
                  6 responses
                  31 views
                  0 likes
                  Last Post RideMe
                  by RideMe
                   
                  Started by tkaboris, Today, 05:13 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post tkaboris  
                  Started by GussJ, 03-04-2020, 03:11 PM
                  16 responses
                  3,282 views
                  0 likes
                  Last Post Leafcutter  
                  Started by WHICKED, Today, 12:45 PM
                  2 responses
                  20 views
                  0 likes
                  Last Post WHICKED
                  by WHICKED
                   
                  Working...
                  X