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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    579 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
    554 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