Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 futtrader, 04-21-2024, 01:50 AM
          4 responses
          41 views
          0 likes
          Last Post futtrader  
          Started by Option Whisperer, Today, 09:55 AM
          1 response
          11 views
          0 likes
          Last Post bltdavid  
          Started by port119, Today, 02:43 PM
          0 responses
          1 view
          0 likes
          Last Post port119
          by port119
           
          Started by Philippe56140, Today, 02:35 PM
          0 responses
          3 views
          0 likes
          Last Post Philippe56140  
          Started by 00nevest, Today, 02:27 PM
          0 responses
          2 views
          0 likes
          Last Post 00nevest  
          Working...
          X