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

Enum Parameter - Type converter

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

    Enum Parameter - Type converter

    I have a parameter which I've used an enum for selection between several strings:

    public enum TimeFrame
    {
    Day1 = 1,
    Days5 = 2,
    Week1 = 3,
    Weeks5 = 4
    }

    I would like the parameter to instead display

    Day 1
    Days 5
    Week 1
    Weeks 5

    How do I write a type converter to do this in Ninja?

    #2
    Hello afshinmoshrefi,

    The variable names used in an enum cannot contain spaces.

    Instead of using enums, perhaps it would be better to supply a string and use an if statement to determine actions based on the value of the string.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I am using an enum for indicator parameter. My question is how can I use a separate string to be displayed in the indicator drop down instead of the enum members?

      Comment


        #4
        Hello afshinmoshrefi,

        An unsupported method of doing this would be to use a list of strings that is added to a collection.

        Attached is an example.
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi,

          I have written a custom enum converter to do exactly this. It is a little bit complicated but can be done.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by bmartz, 03-12-2024, 06:12 AM
          5 responses
          32 views
          0 likes
          Last Post NinjaTrader_Zachary  
          Started by Aviram Y, Today, 05:29 AM
          4 responses
          13 views
          0 likes
          Last Post Aviram Y  
          Started by algospoke, 04-17-2024, 06:40 PM
          3 responses
          28 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by gentlebenthebear, Today, 01:30 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by cls71, Today, 04:45 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X