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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          51 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          142 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          160 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          96 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          275 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X