Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          579 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X