Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Color main price plot

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

    Color main price plot

    I am trying to color the main price bars based on conditions but can't find the code to do so. I have tried all of the following but I don't think I have the syntax right. Any help would be appreciated.

    if ( condition == true)
    {
    Plots[0].Pen = new Pen(Color.Gold);
    Plots[1][0].Pen = Brushes.Gold;
    BarBrush = Plots[1].Color.Gold;

    }

    #2
    Hello EthanHunt,

    Thanks for opening the thread.

    You can programatically change the color of each bar by changing the Brush associated with BarBrush.

    Here is the sample code taken from the help guide:
    Code:
    protected override void OnBarUpdate()
    {
        // Sets the bar color to yellow
        BarBrush = Brushes.Yellow;
     
        // Sets the brush used for the bar color to its default color as defined in the chart properties dialog
        BarBrush = null;
     
        // Sets the bar color to yellow if the 20 SMA is above the 50 SMA and the closing
        // price is above the 20 SMA (see image below)
        if (SMA(20)[0] > SMA(50)[0] && Close[0] > SMA(20)[0])
            BarBrush = Brushes.Yellow;
    }
    https://ninjatrader.com/support/help.../?barbrush.htm

    If you have any additional questions, please don't hesitate to ask.

    Comment


      #3
      That's exactly what I was looking for, thank you.


      Originally posted by NinjaTrader_Jim View Post
      Hello EthanHunt,

      Thanks for opening the thread.

      You can programatically change the color of each bar by changing the Brush associated with BarBrush.

      Here is the sample code taken from the help guide:
      Code:
      protected override void OnBarUpdate()
      {
          // Sets the bar color to yellow
          BarBrush = Brushes.Yellow;
       
          // Sets the brush used for the bar color to its default color as defined in the chart properties dialog
          BarBrush = null;
       
          // Sets the bar color to yellow if the 20 SMA is above the 50 SMA and the closing
          // price is above the 20 SMA (see image below)
          if (SMA(20)[0] > SMA(50)[0] && Close[0] > SMA(20)[0])
              BarBrush = Brushes.Yellow;
      }
      https://ninjatrader.com/support/help.../?barbrush.htm

      If you have any additional questions, please don't hesitate to ask.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      51 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      31 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      165 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      100 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      160 views
      2 likes
      Last Post CaptainJack  
      Working...
      X