• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.

    https://ninjatrader.com/support/help...injascriptprop

    Code:
    [Display(GroupName = "Parameters", Description="Choose a Moving Average Type."), NinjaScriptProperty]
            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 dtl-saw, Yesterday, 08:44 PM
    0 responses
    12 views
    0 likes
    Last Post dtl-saw
    by dtl-saw
     
    Started by ballboy11, Yesterday, 04:29 PM
    0 responses
    10 views
    0 likes
    Last Post ballboy11  
    Started by zacharydw00, Yesterday, 02:29 PM
    2 responses
    30 views
    0 likes
    Last Post zacharydw00  
    Started by timcjpfx, Yesterday, 06:22 AM
    4 responses
    27 views
    0 likes
    Last Post timcjpfx  
    Started by welson, Yesterday, 08:26 AM
    2 responses
    18 views
    0 likes
    Last Post NinjaTrader_PatrickG  
    Working...
    X