Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Painting a line with three different colors

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

    Painting a line with three different colors

    Hi,

    I would like to color an indicator line to be green on the bar where a low pivot in the indicator is formed (MyInd[0] > MyInd[1] && MyInd[2] > MyInd[1]), red for the reverse, and blue otherwise. I looked at the example using ROC in the help guide, but that is based on > or < 0 -- I still tried to replicate it by having three plots, and assigning -1 if another of the plots (effectively, the green, red or blue) was supposed to display and the real value of the indicator otherwise. I then set each plot to have a Plot[n].Min = 0. Somehow, it didn't work. Any thoughts, anyone?

    Meanwhile, I had a strange experience -- when I added the indicator (just the current, working single-color version), all of my paint bar coloring on the main price chart disappeared. The indicator plotted in its pane, #2, price in the pane above it, #1, but some of my code in pane #1 appeared to have stopped working. Hmmm. Has anyone seen that?

    Thanks,

    Gordon

    #2
    Hi Gordon, for the multiplot coloring you can check this reference sample - http://www.ninjatrader-support2.com/...ead.php?t=3227

    Do you get an error in the Log tab if your indicator stops working? You must likely run into this issue - http://www.ninjatrader-support2.com/...ead.php?t=3170

    Comment


      #3
      Gordon, you want to not assign any value to the other two plots to get it to work.

      if ( blue condition )
      {
      BluePlot[0] = value;
      }
      else
      if (red condition)
      {
      RedPlot[0] = value;
      }
      else
      {
      GreenPlot[0] = value;
      }

      You may also want to take the approach of keeping the values in a data series so that you get better line consistency by assigning the previous value to the previous index of the plot you want.

      if ( blue condition)
      {
      BluePlot[1] = dataseries[1];
      BluePlot[0] = dataseries[0];
      }
      etc


      Ninja plots from a start to end point and the default method is the middle of the current bar as the point to start from. Since you only want the bar on which the high/low is then you aren't going to get multiple bars to have the plot actually plot unless you set the start to the previous bar as in the example above.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      576 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 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
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X