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

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.
    JimNinjaTrader Customer Service

    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 TraderBCL, Today, 04:38 AM
      2 responses
      17 views
      0 likes
      Last Post TraderBCL  
      Started by martin70, 03-24-2023, 04:58 AM
      14 responses
      106 views
      0 likes
      Last Post martin70  
      Started by Radano, 06-10-2021, 01:40 AM
      19 responses
      609 views
      0 likes
      Last Post Radano
      by Radano
       
      Started by KenneGaray, Today, 03:48 AM
      0 responses
      5 views
      0 likes
      Last Post KenneGaray  
      Started by thanajo, 05-04-2021, 02:11 AM
      4 responses
      471 views
      0 likes
      Last Post tradingnasdaqprueba  
      Working...
      X