Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ADD() and customize

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

    ADD() and customize

    Is it possible to add an indicator to a strategy, then customize its look?

    Add(SMA(20)); -- I want the line red
    Add(MACD(12.26,9)); -- I want the lines red, white and blue

    Thanks in advance.

    #2
    Hello RiversideDude,

    Thank you for writing in.

    You can use the undocumented collection, Indicators, to select a particular indicator. Then, use PlotColors to modify the colors of each plot: http://ninjatrader.com/support/helpG...plotcolors.htm

    So, for your particular case:
    Code:
    protected override void Initialize()
    {
         Add(SMA(20); // this will be at Indicators[0]
         Add(MACD(12, 26, 9)); // this will be at Indicators[1]
    }
    
    protected override void OnBarUpdate()
    {
         Indicators[0].PlotColors[0][0] = Color.Red;
         Indicators[1].PlotColors[0][0] = Color.Red;
         Indicators[1].PlotColors[1][0] = Color.White;
         Indicators[1].PlotColors[2][0] = Color.Blue;
    }
    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thanks. I actually found that but wasn't sure how that worked. Thanks for the quick reply.
      Does it have to be in OnBarUpdate()?

      Comment


        #4
        Hello RiversideDude,

        You can also do this in Initialize() after you have added your indicators with this different syntax as well:
        Code:
        protected override void Initialize()
        {
             Add(SMA(20));
             Add(MACD(12, 26, 9));
        
             SMA(20).Plots[0].Pen.Color = Color.Green;
        
             MACD(12, 26, 9).Plots[0].Pen.Color = Color.Red;
             MACD(12, 26, 9).Plots[1].Pen.Color = Color.White;
             MACD(12, 26, 9).Plots[2].Pen.Color = Color.Blue;
        }
        Please, let us know if we may be of further assistance.
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Great! I'll give it a try.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          571 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          331 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
          549 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          549 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X