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

Instrument drop down list

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

    Instrument drop down list

    Is there a way to add the instrument dropdown list into one's indicator the same one that is on the charts top left hand corner if so what is the typecast?

    #2
    Hello ballboy11,

    You can use the following syntax to create an Instrument property:

    Code:
    protected override void OnStateChange()
    {
          if (State == State.SetDefaults)
          {
                InstrumentInput = Instrument.GetInstrument("ES 12-18");  
          }
    }
    
    [TypeConverter(typeof(NinjaTrader.Gui.Tools.InstrumentSelector))]
    [Display(Name="Select Instrument", GroupName = "Parameters", Order = 0)]
    public Instrument InstrumentInput
    { get; set; }
    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you. Last question is there a way to for example on the set default section to have the current Instrument loaded. I see your example ES 12- 18 is hard coded. Can one have in your example Have ES update automatically so after rollover it will be ES 03-19 etc.

      Comment


        #4
        Hello ballboy11,

        I don't believe there would be a suggested way to do this for the GUI specifically.

        The states needed to set the property in the user interface would have a null Instrument property so getting the instrument would require you to first apply the script so its later states can run. After the script is already applied, you could reset the value overriding the users choice if necessary.

        You can reset the value of the input after the fact in later states like DataLoaded when the Instrument property is not null but this would override the users choice. You could perhaps add logic in one of the later states to check for rollovers yourself. For example, if the Instrument is ES and your custom picker is ES but the rollover does not match, reset its value.

        I look forward to being of further assistance.





        JesseNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello ballboy11,

          You can use the following syntax to create an Instrument property:

          Code:
          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          InstrumentInput = Instrument.GetInstrument("ES 12-18");
          }
          }
          
          [TypeConverter(typeof(NinjaTrader.Gui.Tools.InstrumentSelector))]
          [Display(Name="Select Instrument", GroupName = "Parameters", Order = 0)]
          public Instrument InstrumentInput
          { get; set; }
          Please let me know if I may be of further assistance.
          Hi Jesse,
          This method can not be serialized ; when saving a template we get an error
          I am currently adding an [XmlIgnore()] to solve that, but of course, the parameter is not saved...
          do you know a way to be able to serialize this ?
          Pablo
          pmaglio
          NinjaTrader Ecosystem Vendor - The Indicator Store

          Comment


            #6
            Hello pmaglio,

            Correct an Instrument is a complex object which cannot be serialized directly. This would be just like a brush if you wanted to save its value, you would need to write your own property for serialization in that use case. An Instrument its self is not expected to be serialized, you could try using a string of the instruments full name instead to avoid this.

            You can find an example of serializing a brush, or the concept of making a serialization property here: https://ninjatrader.com/support/help...definedbrushes


            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by arvidvanstaey, Today, 02:19 PM
            4 responses
            11 views
            0 likes
            Last Post arvidvanstaey  
            Started by samish18, 04-17-2024, 08:57 AM
            16 responses
            61 views
            0 likes
            Last Post samish18  
            Started by jordanq2, Today, 03:10 PM
            2 responses
            9 views
            0 likes
            Last Post jordanq2  
            Started by traderqz, Today, 12:06 AM
            10 responses
            18 views
            0 likes
            Last Post traderqz  
            Started by algospoke, 04-17-2024, 06:40 PM
            5 responses
            48 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X