Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Possible to add [NinjaScriptProperty] to custom enum property?

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

    Possible to add [NinjaScriptProperty] to custom enum property?

    So I have a custom enum that allows the selection of various MA types. The selection works fine, but the way I have it set up as a property, I do not use the [NinjaScriptProperty] tag, or else it throws errors.

    As such, this means I cannot reference the indicator from another indicator, while being able to set that property on the function call.

    So my script...

    In the class level, I declare and initialize a variable:
    Code:
    private [COLOR=#9b59b6]MaType [/COLOR]myMA    = MaType.SMA;

    In the properties section, notice I do not have a 'NinjaScriptProperty' tag there, so I cannot set this variable when caling from another indicator. I have set up the input as follows:
    Code:
    [Display(Name="MA in Calc", Order=4, GroupName = "1)Parameters" )]
    public [COLOR=#9b59b6]MaType [/COLOR]MyMA
    {
        get { return myMA; }
        set { myMA = value; }
    }
    Finally, the enum setup is as follows:
    Code:
    #region Enums
    public enum MaType
    {
       SMA,
       EMA,
       WMA,
       TMA,
       HMA,
       ZLEMA
    }
    #endregion

    Is there a way to add in the [ninjascriptproperty] tag I am unaware of?
    Last edited by forrestang; 12-24-2021, 12:09 AM.

    #2
    Hello forrestang,

    Thanks for your post.

    Enums must be declared outside of the class of the script. Our examples use global enums outside of all namespaces, but you can also put the enums in a custom namespace. When declaring a property of that enum type be sure to use the fully qualified namespace.

    Using NinjaScriptProperty is fine.

    As an example, the DValueArea indicator for NinjaTrader 8 uses enums in a custom namespace and the properties using these enums have the NinjaScriptProperty applied.

    DValueArea: https://ninjatraderecosystem.com/use...ad/dvaluearea/

    I am linking you to this forum thread which you may find to be helpful: https://ninjatrader.com/support/foru...-a-custom-enum

    Let us know if we may assist further.


    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks... I was JUST about to update this thread as I had figured it out. Thanks Brandon.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      580 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      335 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      102 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
      552 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X