Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing indicator colours as part of NT Strategy

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

    Changing indicator colours as part of NT Strategy

    Hi
    How does one change the indicator line (e.g. EMA) colour if part of an NT strategy?

    thx
    David

    #2
    You can do something like:

    Code:
    protected override void Initialize()
    {
        Add(SMA(20));
        SMA(20).Plots[0].Pen.Color = Color.Red;
        CalculateOnBarClose = true;
    }
    RayNinjaTrader Customer Service

    Comment


      #3
      thx - this works a treat.........
      next step, how does one change the colours of both the two lines & histogram for the MACD.

      thx
      David

      Comment


        #4
        The concept is that the Plots[] and Lines[] are arrays holding plot and line objects. If you have a two line plot, you can change the color by accessing either Plots[0] for the first plot, Plots[1] for the second plot and so on...





        Review my sample code to get an idea of how you could replicate this for the MACD indicator.
        RayNinjaTrader Customer Service

        Comment


          #5
          great - easy to code; work a treat. thx for your help !
          David

          Comment


            #6
            OK - hopefully final question on this thread. I am now struggling to change the thickness of the MACD histogram! How can I resolve this one. thx !!!!
            David

            Comment


              #7
              On the indicator properties: Right click->Indicators

              Comment


                #8
                thx. but would like to integrate into the coded strategy....pls refer to earlier notes on this. thx. David

                Comment


                  #9
                  Try:

                  SMA(20).Plots[0].Pen.Width = 2;
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    thx Ray ! it works

                    Comment


                      #11
                      I am having a problem controlling the Plot Color. I have an indicator that has one plot that was generated by the wizard:

                      Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Bar, "ChangeFromOpen"));

                      I am assuming that this is stored in Plots[0].

                      The indicator works until I add the following code to the OnBarUpdate method to try and manipulate the color of the plot (the code was copied directly from the help example):

                      if (Values[0] > 100)
                      Plots[0].Pen = new Pen(Color.Blue);
                      else
                      Plots[0].Pen = new Pen(Color.Red);

                      I get the compiler error: Operator '>' cannot be applied to operands of type 'NinjaTrader.Data.DataSeries' and 'int'

                      If I try and compare it to 100.0 then I get the same error message except 'double' instead of 'int'

                      Any help would be greatly appreciated.
                      Last edited by higler; 08-01-2007, 05:14 PM. Reason: Clarification

                      Comment


                        #12
                        Values[0] returns a DataSeries at that index. To get the value of try something like:

                        Values[0][0]

                        Also, no need to create a new Pen object. Best to avoid creating new objects if you do not have to.

                        Plots[0].Pen.Color = Color.Red;
                        '
                        will work for example.
                        RayNinjaTrader Customer Service

                        Comment


                          #13
                          Thanks. That works.

                          Comment


                            #14
                            If I have an indicator with three plots, is there a way to programmatically turn off/on the price markers for the individual plots? Thanks.

                            Comment


                              #15
                              Unfortunately this can only be programatically controlled at the indicator level for all price markers, not individually.
                              RayNinjaTrader Customer Service

                              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
                              550 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X