Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Chart background color

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

    Chart background color

    Hi,
    I would like to spilt the chart into a few sections which each section chart background will be in a different background color (behind the bars)
    how can i dynamically change the chart background color ?
    And what if i also would like to set the background only between price range (like a box)

    Thanks

    #2
    Hi yaniv,

    You can use the BackBrush object within the OnBarUpdate() function to change the chart background color.

    Code:
    protected override void OnBarUpdate() {
        // Sets the chart panel back color to pale green
        BackBrush = Brushes.PaleGreen;
     
        // Sets the back color to to null which will use the default color set in the chart properties dialog window
        BackBrush = null;
     
        // Sets the back color to maroon when the closing price is less than the 20 period SMA // and to lime green when above
        BackBrush = SMA(20)[0] >= Close[0] ? Brushes.Maroon : Brushes.LimeGreen;
    }
    To set the background for a specific price range (like a box), use the SharpDX.Direct2D1.RenderTarget.FillRectangle() function.

    For more information about the FillRectangle() function and BackBrush objects, you can refer to the following links and the attached file below:




    Attached Files
    Last edited by ninZa; 09-06-2024, 06:51 AM.
    ninZa
    NinjaTrader Ecosystem Vendor - ninZa.co

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    72 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    39 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X