Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exclude indicator from indicators dialog

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

    Exclude indicator from indicators dialog

    Hi NinjaTrader team,

    is there a way to exclude an indicator from the indicators dialog? Like I can exclude an indicator property from the property sheet using Browsable(false)?

    I'd like to host some indicators inside strategies or other indicators, so I can use indicator instances as building blocks to reuse some code for recurring tasks, but I don't want the indicators to be available as standalone indicators in the indicators dialog.

    Thanks,
    Heiko


    #2
    Hi Heiko, thanks for posting. You can make a partial class to create shared code that will not show up in the indicators list. See the example here:
    I have class called Logger... I want to use this class inside indicator or strategy (ninjatrader objects). This Logger class should write text using Time[0],


    Kind regards,
    -ChrisL

    Comment


      #3
      Originally posted by schwarzerh View Post
      ... as building blocks to reuse some code for recurring tasks, but I don't want the indicators to be available as standalone indicators in the indicators dialog.
      Try using an abstract base class.

      Good reading here.

      Comment


        #4
        Hi Chris, hi bltdavid,

        thanks for your help - I think bltdavid understood what I was trying to express. And, obviously this discussion has already been going on for a while :-)

        Here are my two cents. Consider this code snippet

        Code:
        using NinjaTrader.Custom.AddOns.Schwarzer.Framework.Condition;
        using NinjaTrader.Custom.AddOns.Schwarzer.Framework.Visualization;
        
        namespace NinjaTrader.NinjaScript.Indicators.Schwarzer.Experimental
        {
            /**
            * <author>Heiko Schwarzer</author>
            */
            public abstract class ConditionVisualizer : Indicator
            {
                private ICondition _condition;
                private IViewElement _viewElement;
        
        
                protected override void OnStateChange()
                {
                    if (State == State.DataLoaded)
                    {
                        _condition = CreateCondition();
                    }
                }
        
        
                protected abstract ICondition CreateCondition();
        
        
        
                protected override void OnBarUpdate()
                {
                    if (_condition.IsTrue())
                    {
                        if (_viewElement == null)
                        {
                            _viewElement = CreateViewElement();
                            _viewElement.Paint();
                        }
        
                        return;
                    }
        
                    if (_condition.IsFalse() && _viewElement != null)
                    {
                        _viewElement.Remove();
                        _viewElement = null;
                    }
                }
        
        
                protected abstract IViewElement CreateViewElement();
            }
        }​

        Now I have an abstract indicator base class which I can derive from. Simply implement CreateCondition() and CreateViewElement(), and you can have, for instance, an indicator that plots a little triangle at the low or high of each reversal bar, In reality, this base class would be more complex, of course, I am trying to keep it simple for discussion purposes. You have to use a little imagination ...

        Now, here comes the point:

        I'd like the implementations of ICondition (and maybe also IViewElement) in this example to be instances of Indicator. So they can have their own data feed. So they can use their plot capabilities. So they can trigger an alert. etc. etc.

        Think something like

        Code:
        using NinjaTrader.Custom.AddOns.Schwarzer.Framework.Condition;
        
        namespace NinjaTrader.NinjaScript.Indicators.Schwarzer.Experimental
        {
            /**
            * <author>Heiko Schwarzer</author>
            */
            public class ReversalBarCondition : Indicator, ICondition
            {
                public bool IsTrue()
                {
                    return (Value[0] > 0);
                }
        
                public bool IsFalse()
                {
                    return !IsTrue();
                }
        
                protected override void OnBarUpdate()
                {
                    if (CurrentBar == 0)
                    {
                        return;
                    }
        
                    if (High[0] > High[1] && Close[0] < Close[1])
                    {
                        Value[0] = 1;
                    }
                }
            }
        }
        ​

        This way we could construct an entire component framework where you can easily reuse framework classes like ConditionVisualizer and also ICondition implementations like ReversalBarCondition in different contexts. Because of the infrastructure it provides, Indicator would serve as a perfect base class to construct reusable components from.

        The only problem is:

        ReversalBarCondition from the above example would need to be a concrete Indicator implementation which would be listed in the indicators dialog.

        Which you would not want. Because it is only a component to be hosted inside another indicator or a strategy.

        So how about a Browsable(false) annotation applicable to the indicator class?

        Hope this helps the discussion. Any feature request in that direction would have my support. I would even implement it if NinjaTrader accepts me as a freelance contractor :-)

        Regards,
        Heiko
        Last edited by schwarzerh; 11-25-2022, 02:54 AM.

        Comment


          #5
          Hey, you did it !

          Thank you very much, NinjaTrader Team !

          :-)

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          574 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          332 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X