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 sjsj2732, 03-23-2026, 04:31 AM
          0 responses
          76 views
          0 likes
          Last Post sjsj2732  
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          313 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          311 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          149 views
          1 like
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          111 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Working...
          X