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 Rapine Heihei, 04-23-2024, 07:51 PM
            2 responses
            30 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by Shansen, 08-30-2019, 10:18 PM
            24 responses
            942 views
            0 likes
            Last Post spwizard  
            Started by Max238, Today, 01:28 AM
            0 responses
            9 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by rocketman7, Today, 01:00 AM
            0 responses
            4 views
            0 likes
            Last Post rocketman7  
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            28 views
            0 likes
            Last Post wzgy0920  
            Working...
            X