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

How to set the default input series

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

    How to set the default input series

    How can I set the default input series of an indicator? By default it is Close. How do I, for example, have it default to High?

    Thanks,
    Wil

    #2
    Hello wbennettjr, thanks for your post.

    There is no way to select a default input series from the UI. You can code the indicator itself to only use to High series e.g.

    if(High[0] > High[1])
    { // code here }

    Edit:

    A programmer could just have a property that asks the user what series to use e.g. "UseXAsDefaultInput" when that is true, use the X series (Low, High, etc) when it is false, use the default input.

    Please let me know if I can assist any further.
    Last edited by NinjaTrader_ChrisL; 02-20-2020, 02:56 PM.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chris,

      I guess I wasn't clear. I wasn't asking about from the UI. In the SetDefaults state, is there any code that can be used to set the input to something else? If not, can that be added as a feature request?

      Thanks,
      Wil

      Comment


        #4
        Hi Wil, thanks for your reply.

        One could make an enum public property that holds values Open, High, Low, or Close. The user would select one of them and depending on the value, use the proper price series e.g.

        Code:
        if(UseClose)
        {
            //Set up indicators to use Close series
        }
        
        else if(UseHigh)
        {
            //Set up indicators to use High series
        }
        
        //and so on
        For an example on setting up an enum property see here:


        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Thanks Chris,

          Unfortunately, you still seem to not understand what I'm asking for . Let me try again:
          • The NinjaScriptBase class has an Inputs property
          • The NinjaScriptBase class has an Input property
          • The NinjaScriptBase class has an InputUI property
          • The NinjaScriptBase class has a SetInput method (With EditorBrowsableState.Never)
          • Indicators use the Input property to perform calculations
          • When you create an indicator, by default Input is set to Close
          • If you edit the indicator in the UI, you can change Input to something else
          So the question is: How can I change the Input property in code?

          I have tried the following but they don't work (using High as an example):
          • Inputs[0] = High
          • SetInput(High)
          • InputUI = High

          Thanks,
          Wil
          Last edited by wbennettjr; 02-22-2020, 09:30 AM. Reason: Added InputUI

          Comment


            #6
            Hello wbennettjr, thanks for your reply.

            The Input series will be what the user selects as the Input Series on the UI. That will not be saved in a template, so why not have a property that asks the user what series to use, and use the selected series in a large IF block in the code?
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Chris,

              I exclusively use Open as the series whenever I work with indicators. One of the biggest problems I have is that I add an indicator and forget to change the series. If I can change the default (as with other properties I use), I can create a partial Indicator class to set the value so that *ALL* indicators will default to that. What you proposed gives me no improvement over the current situation. As a matter of fact, it makes it worse.

              As an example, if I want to make it so that PaintPriceMarkers = false is the default for *ALL* indicators, I would do the following:

              Code:
              public partial class Indicator
              {
                  public override void SetState(State state)
                  {
                      base.SetState(state);
              
                      if (state == State.SetDefaults)
                      {
                          PaintPriceMarkers = false;
                          // Would like to set Input = Open here
                      }
                  }
              }
              This will affect *ALL* indicators and I don't have to modify each one to use some custom property.

              If I can change the input to Open, then *ALL* indicators would default to using the Open series and I wouldn't have to remember to change it each time I add an indicator.

              I hope you can see now that the solution you proposed is not appropriate for the situation. I would be adding a property that serves the same purpose as the existing property. That does nothing to help me to remember to change the property. Even if that made sense, it would only work for indicators I create and not the stock indicators. All the stock indicators use Input as the source.

              Thanks,
              Wil

              Comment


                #8
                Just to state the obvious:

                As you stated, the value can be changed from the UI. What I'm looking for is the code the UI uses to change the value. I don't have access to the UI code so I have to ask the question here. So, to be clear, the answer to my question is simply the code that is run when you select a series from the UI. It should likely be no more than a couple of lines.

                If the code is not accessible somehow, then I would like to submit a feature request to enable this scenario.

                Thanks,
                Wil

                Comment


                  #9
                  Hi Wil, thanks for the follow up.

                  I submitted a feature request to add the ability to set the default input through NinjaScript.

                  I'll report here once I receive the feature tracking ID.

                  Kind regards,

                  -ChrisL
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks Chris!

                    Comment


                      #11
                      wbennettjr, i think this might be possible with reflection (until NT implements [if ever] your request).



                      i.e.
                      if (state == State.SetDefaults) { propertySet(this, "Input", Open); ... however, i havent tested, just shared my thoughts & snippet.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by mmenigma, Today, 02:22 PM
                      1 response
                      3 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by frankthearm, Today, 09:08 AM
                      9 responses
                      35 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      Started by NRITV, Today, 01:15 PM
                      2 responses
                      9 views
                      0 likes
                      Last Post NRITV
                      by NRITV
                       
                      Started by maybeimnotrader, Yesterday, 05:46 PM
                      5 responses
                      26 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by quantismo, Yesterday, 05:13 PM
                      2 responses
                      21 views
                      0 likes
                      Last Post quantismo  
                      Working...
                      X