Announcement

Collapse
No announcement yet.

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.

    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.





        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.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            80 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            40 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            63 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            63 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            54 views
            0 likes
            Last Post CarlTrading  
            Working...
            X