Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to reference a Plot or a Line

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

    How to reference a Plot or a Line

    In the attached code, I'm trying to color the Zeroline based on the value of "Diff". On lines 90 and 96 of the code, the PlotColors are referencing Index 4. Index 4 is an "Add" statement to add a line in the "Initialize" section. Are Add lines and Add Plots different from an Indexing point of view?

    I've been looking at this for a long time and can't figure it out. When Diff is positive I want to color the line Green, when the Diff is negative, I want to color the line Red.

    I'd appreciate it if someone can point me in the right direction.

    Thanks...
    Taddypole...
    Attached Files

    #2
    Taddypole, in the code you posted, there are only four Add() references. Please change PlotColors[4][0] to PlotColors[3][0] and see if that fixes it.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Austin,

      I tried all values from 0 to 3 and the only one that made any difference is 2. Using 2 for a reference changed the color of the Difference oscillator but not the zeroline. Refer to the attached picture.

      I'm totally stumped on this one...
      Attached Files

      Comment


        #4
        Taddypole, sorry I overlooked this earlier, but to change the color of a line, it must be created as a plot. Please try creating a zero "line" as a plot with a value of 0 every bar and changing that plot color.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Also, in case you haven't seen it, here is the reference sample for how to color plots with the NT7 approach.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Originally posted by Taddypole View Post
            In the attached code, I'm trying to color the Zeroline based on the value of "Diff". On lines 90 and 96 of the code, the PlotColors are referencing Index 4. Index 4 is an "Add" statement to add a line in the "Initialize" section. Are Add lines and Add Plots different from an Indexing point of view?

            I've been looking at this for a long time and can't figure it out. When Diff is positive I want to color the line Green, when the Diff is negative, I want to color the line Red.

            I'd appreciate it if someone can point me in the right direction.

            Thanks...
            Taddypole...
            Code:
            if (Diff > 0) Lines[int index].Pen.Color = Color.Green;
            else if (Diff < 0) Lines[int index].Pen.Color = Color.Red;
            where int index is the index of the line whose color you want to change.

            Comment


              #7
              Thank you Austin and koganam...

              I now have both methods working.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              608 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              355 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              105 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              560 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              561 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X