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

NinjaScript Editor - Custom Dropdown Lists?

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

    NinjaScript Editor - Custom Dropdown Lists?

    Hello!

    I'm new to NinjaTrader (as a recent convert from FXCM due to the debacle.)

    I've started migrating a lot of my indicators (currently written in Lua) and many of them have a dropdown list so the user can select from multiple options, where a Boolean choice isn't sufficient.

    For example, suppose I want to give the user 3 options for performing a calculation based on a bar's size: High-Low, Open-Close, High-Close.

    Is there a way I can create a dropdown list with these parameters? Maybe an enumeration of types? Or is the only alternative to use a string input field where the user specifies code values?

    Thanks in advance for your help!

    #2
    Hello MarkWise, and thank you for your question.

    C# does indeed have an enum type, and these can be exposed as properties. If you would like to map simple types to values meaningful to the program, a C# dictionary can help with this as well. The attached code sample should help get you started. Please let us know if there are any other ways we can help.
    Attached Files
    Last edited by NinjaTrader_JessicaP; 02-09-2017, 11:03 AM.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      That's exactly what I was looking for!

      I*didn't know*if that was supported.

      Thanks so much!

      Comment


        #4
        I'm running into namespacing issues now... The auto-generated NinjaScript code doesn't include the proper namespacing for any enumerations included in the main indicator.

        This occurs within the MarketAnalyzerColumn section and the Strategy section.

        Basically the enumerations get included as "Indicators.MyIndicator.MyEnumType" but they should be included as "Indicators.Indicators.MyIndicator.MyEnumType" .

        This also occurs in the DaysOfWeekEnumExample.cs file provided.

        Am I doing something wrong?

        Comment


          #5
          Namespacing Issues with Enum Parameters

          Here is a sample indicator demonstrating the issue. If you manually add the namespacing references, as soon as you compile, the auto-generated code removes those references.

          Thoughts?
          Attached Files

          Comment


            #6
            I was able to get this to work finally. I had to put the enum declaration(s) into a new namespace OUTSIDE of the main namespace area, but below the Indicator class definition.

            Note that the NinjaTrader compiler does NOT like multiple sub namespacing. That is, NamespaceParent.Child is okay, but NamespaceParent.Child.AnotherChild is not okay.
            Attached Files

            Comment


              #7
              thanks for this dropdown list code

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by proptrade13, Today, 11:06 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by quantismo, 04-17-2024, 05:13 PM
              4 responses
              30 views
              0 likes
              Last Post quantismo  
              Started by love2code2trade, 04-17-2024, 01:45 PM
              4 responses
              32 views
              0 likes
              Last Post love2code2trade  
              Started by cls71, Today, 04:45 AM
              2 responses
              10 views
              0 likes
              Last Post eDanny
              by eDanny
               
              Started by kulwinder73, Today, 10:31 AM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Erick  
              Working...
              X