NinjaScript > Language Reference > Indicator >

PlotColors

Print this Topic Previous pageReturn to chapter overviewNext page

Definition

Holds an array of color series objects holding historical bar colors. A color series object is added to this array when calling the Add() 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
PlotColors[int PlotIndex][int barsAgo]

 

 

Examples

protected override void Initialize()
{
    // Add two plots
    Add(new Plot(Color.Blue, PlotStyle.Line, "Upper"));

    Add(new Plot(Color.Orange, PlotStyle.Line, "Lower"));
}
 
protected override void OnBarUpdate()
{

    // Sets values to our two plots

    Upper.Set(SMA(High, 20)[0]);

    Lower.Set(SMA(Low, 20)[0]);
 

    // Color the Upper plot based on plot value conditions
    if (Rising(Upper))
         PlotColors[0][0] = Color.Blue;

    else if (Falling(Upper))

         PlotColors[0][0] = Color.Red;

    else

         PlotColors[0][0] = Color.Yellow;

 

    // Color the Lower plot based on plot value conditions

    if (Rising(Lower))
         PlotColors[1][0] = Color.Blue;

    else if (Falling(Lower))

         PlotColors[1][0] = Color.Red;

    else

         PlotColors[1][0] = Color.Yellow;
}