Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding Indicator to Chart Question

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

    Adding Indicator to Chart Question

    I know you can add an indicator to a chart in a strategy. Can you also stipulate the color and width of the lines? For example, if I wanted to add SMA to my chart, in my strategy, under the protected override void Initialize() section, I can simply put "Add(SMA(5)); ........ but can I add something to this line to make in a color of red with a width of 3?

    #2
    Hello edgeliner,
    Yes, you can do it.

    For example if you are adding an SMA then you can set the color and the width using the below code
    Code:
    protected override void Initialize()
    {
      SMA(14).Plots[0].Pen.Color = Color.Green;
      SMA(14).Plots[0].Pen.Width = 3;
      Add(SMA(14));
      //rest of the code
    }
    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Great....Thanks! What if you wanted to add the Bollinger bands and wanted the upper and lower to be black and the middle to be red??

      Comment


        #4
        Hello edgeliner,
        You have to use the appropriate plot index to do it. Please use the below code to do it

        Code:
        this.Bollinger(2,14).Plots[2].Pen.Color = Color.Black;
        this.Bollinger(2,14).Plots[1].Pen.Color = Color.Black;
        this.Bollinger(2,14).Plots[0].Pen.Color = Color.Red;
        Add(this.Bollinger(2,14));
        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        148 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        71 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        125 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        79 views
        0 likes
        Last Post PaulMohn  
        Working...
        X