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

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
    BertrandNinjaTrader Customer Service

    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 kujista, Today, 05:44 AM
      0 responses
      5 views
      0 likes
      Last Post kujista
      by kujista
       
      Started by ZenCortexCLICK, Today, 04:58 AM
      0 responses
      5 views
      0 likes
      Last Post ZenCortexCLICK  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      172 responses
      2,281 views
      0 likes
      Last Post sidlercom80  
      Started by Irukandji, Yesterday, 02:53 AM
      2 responses
      18 views
      0 likes
      Last Post Irukandji  
      Started by adeelshahzad, Today, 03:54 AM
      0 responses
      8 views
      0 likes
      Last Post adeelshahzad  
      Working...
      X