Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Passing period parameter to Add function as a variable

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

    Passing period parameter to Add function as a variable

    Hi. I tried to pass an integer value to the Add function to populate the period parameter, but it did not work.


    // where my_int is declared as a int variable
    my_int = 5;

    Add(PeriodType.Minute, my_int);


    Is there a way to accomplish the goal of calling Add with a variable value for period, rather than a static constant?

    Thank you.


    Regards,

    William

    #2
    Provided that the variable value my_int is the value you want prior to using it in the Add() method, this will work.

    Try adding a Print(my_int) just before calling the Add() method to ensure the value is initialized as you expect.
    RayNinjaTrader Customer Service

    Comment


      #3
      Am I right in assuming that there is no way to use user supplied inputs in the Add method, as they are not available yet when Initialize is called?

      Comment


        #4
        You can use user inputs (properties) in the Add() method called within the Initialize() method.
        RayNinjaTrader Customer Service

        Comment


          #5
          Ray,

          Could you please clarify your statement:

          You can use user inputs (properties) in the Add() method called within the Initialize() method.
          Is it possible to pass in a value via parameter inputs, define the period of the Add() method, and then iterate these values via the optimizer in the Strategy Analyzer? It appears the process to pass in this period value works in a Chart and when backtesting, but not during optimization operations. Please confirm.

          Regards,

          Whitmark
          whitmark
          NinjaTrader Ecosystem Vendor - Whitmark Development

          Comment


            #6
            I have never tried that in optimization. If you have and it does not work, then that is current expected behaviour.
            RayNinjaTrader Customer Service

            Comment


              #7
              As you can image, it can be pretty handy to use the optimizer to get a feel for the right combination of multiple timeframes or, for that matter, multiple instruments (enumerated of course) to be used within a strategy. Can we consider this for the enhancement list? Thanks.

              Whitmark
              whitmark
              NinjaTrader Ecosystem Vendor - Whitmark Development

              Comment


                #8
                Yes, this is already on our list.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Do you know which version and when the ETA is? I am very interested in this.

                  Comment


                    #10
                    Unfortunately there no ETA available yet.

                    Comment


                      #11
                      Has the ability to pass in the PeriodType and Period Size for a secondary series via a parameter AND allow these parameters to be iterated in the optimizer been considered yet for Version 7? Thanks.

                      Whitmark
                      whitmark
                      NinjaTrader Ecosystem Vendor - Whitmark Development

                      Comment


                        #12
                        Thanks for the note whitmark. We will put it on the list for considerations.
                        Josh P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        558 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        324 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        101 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        545 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        547 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X