Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Set general parameter defaults in code

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

    Set general parameter defaults in code

    For non-custom strategy properties/parameters how can we set the default value in code?

    E.g., when I copy a strategy to a new editor I also want my defaults for things like "Data Series Value" and "Min bars required" to come along with it, just as the defaults I assign to custom parameters are defined in the code.

    #2
    Hi dbooksta,

    For items that are not public properties, these need to be set in Initialize().

    For example:
    Code:
    protected override void Initialize() 
    { 
        BarsRequired = 20;
    }
    In general, if you look up the special variable in the help guide, the placement of the variable will be in the example.

    Below is a link to the help guide on BarsRequired.
    http://www.ninjatrader.com/support/h...srequired2.htm

    Also, take a look at Calculate on bar close.
    http://www.ninjatrader.com/support/h...onbarclose.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks.

      I can't find all the properties in that help section. For example, how do I set the Data series Value and Type?

      Comment


        #4
        Hello dbooksta,

        Here is a link to the alphabetical reference of methods, special variables, and collections so that you may look up items alphabetically instead of using the search feature of the help guide.
        http://www.ninjatrader.com/support/h..._reference.htm

        For Value(s[0]) you can set this in OnBarUpdate, OnPositionUpdate, OnMarketData, OnMarketDepth, and OnExecution.

        Value is set with:

        Value.Set(11.11);

        Below is a link to Value.
        http://www.ninjatrader.com/support/h.../nt7/value.htm
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          That doesn't look like what I'm referring to. For example, I want to set the default Data series -- i.e., the bars passed to OnBarUpdate() -- to be 5 minute bars. How can I do that?

          Comment


            #6
            Hi dbooksta,

            The primary data series (bar type and interval) will be the dataseries of the chart (or if you are adding a strategy to the Strategies tab of the Control Center, the dataseries will be the dataseries chosen in the strategy's parameters).

            You are able to add additional dataseries using the Add() method.

            For example:

            Add("ES 06-14", PeriodType.Minute, 5);

            Below is a link to the help guide on Add().
            http://www.ninjatrader.com/support/h...s/nt7/add3.htm

            (edit)

            Further you should look into BarsInProgress and BarsArray to see how to find which dataseries is processing and how to call an indicator using a secondary series.

            http://www.ninjatrader.com/support/h...inprogress.htm

            http://www.ninjatrader.com/support/h.../barsarray.htm
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              The primary data series (bar type and interval) will be the dataseries of the chart (or if you are adding a strategy to the Strategies tab of the Control Center, the dataseries will be the dataseries chosen in the strategy's parameters).
              My objective is to have the Strategy code tell the Control Center what default bar type and interval to use, so that when I copy or paste Strategy code I (or collaborators) don't have to remember to manually set those values in the Control Center. Based on what you've said it sounds like this is not presently possible?

              Comment


                #8
                Hi dbooksta,

                It is not possible with NinjaTrader to change the primary data series in any way from a script.

                This is by design.

                Please let me know if I may be of further assistance.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                571 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                331 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
                549 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                550 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X