Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exposing Indicator properties as Strategy Properties

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

    Exposing Indicator properties as Strategy Properties

    I'm building a custom strategy that uses EMA indicator.


    Is there a way to expose the EMA itself as a property of my strategy? Or do I have to create new variables for each property of the EMA and set/get them individually?


    e.g. This is what I want to do - The script editor complains of a recursive property that will crash NinjaTrader

    public class MyStrat : Strategy
    {
    private EMA ema1;

    ...
    ...


    [NinjaScriptProperty]
    [Display(Name="The EMA", Order=1, GroupName="Parameters")]
    public EMA ema1
    { get; set; }

    mattbsea
    NinjaTrader Ecosystem Vendor - mattbsea

    #2
    Hello mattbsea,

    Thank you for your post.

    How exactly are you trying to use the EMA? It isn't clear to me from this example what having the EMA as a property will do for the script. As in, what information are you trying to get from the user about the EMA?

    Are you looking for a user-defined period for the EMA? Or do you want a property that allows the user to pick from a list of pre-defined indicators, such as the EMA?

    I look forward to your response.

    Comment


      #3
      Here's a code example of what I want to do - I have a number of indicators and trying to see if there's a way to just set the indicator as a Property so the Strategy configuration window will automatically show the indicator properties.


      Code:
      namespace NinjaTrader.NinjaScript.Strategies
      {
        public class MyCustomStrategy : Strategy
        {
        ...
        ...
        
      #region Properties
      
      [NinjaScriptProperty]
      [Display(Name="Bollinger", Order=1, GroupName="Parameters")]
      public Bollinger bbands
      { get; set; }
      
      [NinjaScriptProperty]
      [Display(Name="EMA", Order=1, GroupName="Parameters")]
      public EMA ema
      { get; set; }
      ​
      
      #endregion
      ​
        }
      }
      
      
      ​
      mattbsea
      NinjaTrader Ecosystem Vendor - mattbsea

      Comment


        #4
        Hello,

        Thank you for your response.

        There is unfortunately no way to have the strategy automatically show the indicator properties. Any property you want the strategy to have in the 'Properties' window will need to be hard coded.

        The Help Guide page below goes over how to create user-defined inputs.



        Please let us know if you have any further questions.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        65 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        139 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X