PlotColors

Description

PlotColors is a collection that contains all color series of all plot objects.

When a plot is added using the Add() method it automatically creates a color series object and is added to the PlotColors collection.

The order of the add commands determines how the plot colors are sorted. The first information request of Add() will create PlotColors[0], the following information request will create PlotColors[1] etc.

Usage

PlotColors[int PlotIndex][int barsAgo]

More Information

More information regarding the collection class: Collection Class

Example

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using TradersYardX.API;
namespace TradersYardX.UserCode
{
[Description("PlotColor Demo")]
public class PlotColorsDemo : UserIndicator
{
public DataSeries SMA20 { get {return Outputs[0];} }
public DataSeries SMA50 { get {return Outputs[1];} }
public DataSeries SMA100 { get {return Outputs[2];} }
private Pen pen;
protected override void OnInit()
{
// Set line strength (width) to 4
pen = new Pen(Color.Empty, 4);
// Add three plots with the defined line strength to the chart
Add(new OutputDescriptor(pen, OutputSeriesDisplayStyle.LevelLine, "SMA20" )); //attached to PlotColors[0]
Add(new OutputDescriptor(pen, OutputSeriesDisplayStyle.LevelLine, "SMA50" )); //attached to PlotColors[1]
Add(new OutputDescriptor(pen, OutputSeriesDisplayStyle.LevelLine, "SMA100")); //attached to PlotColors[2]
IsOverlay = true;
}
protected override void OnCalculate()
{
// Add values to the three plots
SMA20.Set (SMA(20) [0]);
SMA50.Set (SMA(50) [0]);
SMA100.Set(SMA(100)[0]);
// Change colors depending on the trend
if (IsSerieRising(Close))
{
    PlotColors[0][0] = Color.LightGreen;
    PlotColors[1][0] = Color.Green;
    PlotColors[2][0] = Color.DarkGreen;
}
else if (IsSerieFalling(Close))
{
    PlotColors[0][0] = Color.LightSalmon;
    PlotColors[1][0] = Color.Red;
    PlotColors[2][0] = Color.DarkRed;
}
else
{
    PlotColors[0][0] = Color.LightGray;
    PlotColors[1][0] = Color.Gray;
    PlotColors[2][0] = Color.DarkGray;
}
}
}
}

Last updated