BarBrush

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Common > Drawing >

BarBrush

Previous page Return to chapter overview Next page

Definition

Sets the brush used for painting the color of a price bar's body.

 

Property Value

A Brush object that represents the color of this price bar.

 

Tip: To set the price bar color to an empty color which uses the default bar color property, set the BackBrush to null for that bar.

 

Syntax

BarBrush

 

Warning:  You may have up to 65,535 unique BarBrush instances, therefore, using static predefined brushes should be favored.  Alternatively,  in order to use fewer brushes, please try to cache your custom brushes until a new brush would actually need to be created.

 

 

Examples

ns


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;
}