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

How to call an indicator with ENUMs in its properties

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

    How to call an indicator with ENUMs in its properties

    New to C#.

    If I wanted to call an indicator that has enums as part of it's properties (i.e. user settable from the ui) how could they be set from within the calling code?

    For example, in the example code "SampleUniversalMovingAverage" the moving average type, which drives a switch/case block within the indicator, is not shown within the method's signature.
    Is there an elegant way to use enums so they can be set from within other calling methods and optimized later also? Or do I need to remove enums and use something like an int with various values being equivalent to each enum (but this approach obviously is not ideal)....

    Thanks in advance.

    #2
    Hello lavalampmj,

    This is because this indicator was not programmed with an input. You would just need to add the NinjaScriptProperty attribute to the property to make it an input.



    Code:
    [Display(GroupName = "Parameters", Description="Choose a Moving Average Type.")[B], NinjaScriptProperty][/B]
            public CustomEnumNamespace.UniversalMovingAverage MAType
            {
                get { return maType; }
                set { maType = value; }
            }
    After recompiling you could then access this from other files like the following:
    Code:
    SampleUniversalMovingAverage(CustomEnumNamespace.UniversalMovingAverage.SMA);

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by sidlercom80, 10-28-2023, 08:49 AM
    166 responses
    2,234 views
    0 likes
    Last Post sidlercom80  
    Started by thread, Yesterday, 11:58 PM
    0 responses
    1 view
    0 likes
    Last Post thread
    by thread
     
    Started by jclose, Yesterday, 09:37 PM
    0 responses
    6 views
    0 likes
    Last Post jclose
    by jclose
     
    Started by WeyldFalcon, 08-07-2020, 06:13 AM
    10 responses
    1,414 views
    0 likes
    Last Post Traderontheroad  
    Started by firefoxforum12, Yesterday, 08:53 PM
    0 responses
    11 views
    0 likes
    Last Post firefoxforum12  
    Working...
    X