> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# BarBrush

## 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.

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

## Syntax

BarBrush

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

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