PlotBrushes

View as Markdown

Definition

Holds an array of color series objects holding historical bar colors. A color series object is added to this array when calling the AddPlot() method in a custom Indicator for plots. Its purpose is to provide access to the color property of all bars.

Property Value

An array of color series objects.

Syntax

PlotBrushes[int PlotIndex][int barsAgo]

Examples

1protected override void OnStateChange()
2{
3 if(State == State.SetDefaults)
4 {
5 Name = "Example Indicator";
6 // Add two plots
7 AddPlot(Brushes.Blue, "Upper");
8 AddPlot(Brushes.Orange, "Lower");
9 }
10}
11
12protected override void OnBarUpdate()
13{
14 // Sets values to our two plots
15 Upper[0] = SMA(High, 20)[0];
16 Lower[0] = SMA(Low, 20)[0];
17
18 // Color the Upper plot based on plot value conditions
19 if (IsRising(Upper))
20 PlotBrushes[0][0] = Brushes.Blue;
21 else if (IsFalling(Upper))
22 PlotBrushes[0][0] = Brushes.Red;
23 else
24 PlotBrushes[0][0] = Brushes.Yellow;
25
26 // Color the Lower plot based on plot value conditions
27 if (IsRising(Lower))
28 PlotBrushes[1][0] = Brushes.Blue;
29 else if (IsFalling(Lower))
30 PlotBrushes[1][0] = Brushes.Red;
31 else
32 PlotBrushes[1][0] = Brushes.Yellow;
33}
34
35public Series<double> Upper
36{
37 get { return Values[0]; }
38}
39
40public Series<double> Lower
41{
42 get { return Values[1]; }
43}