AddPlot()
<< Click to Display Table of Contents >> AddPlot() |
Adds plot objects that define how an indicator or strategy data series render on a chart. When this method is called to add a plot, an associated Series<double> object is created held in the Values collection.
Note: Plots are ONLY visible from the UI property grid when AddPlot() is called from State.SetDefaults. If your indicator or strategy dynamically adds plots during State.Configure, you will NOT have an opportunity to select the plot or to set the plot configuration via the UI. Alternatively, you may use custom public Brush, Stroke, or PlotStyle properties which are accessible in State.SetDefaults and pass those values to AddPlot() during State.Configure. Calling AddPlot() in this manner should be reserved for special cases. Please see the examples below. |
Determines if the plot(s) used in an indicator are configurable within the indicator dialog window. |
|
An offset value that shifts the visually displayed value of an indicator. |
|
Holds an array of color series objects holding historical bar colors. |
|
A collection holding all of the Plot objects that define their visualization characteristics. |
AddPlot(Brush brush, string name)
AddPlot(Stroke stroke, PlotStyle plotStyle, string name)
Warning: This method should ONLY be called within the OnStateChange() method during State.SetDefaults or State.Configure |
brush |
A Brush object used to construct the plot |
name |
A string representing the name of the plot |
plotStyle |
A PlotStyle object used to construct the style of the plot
Possible values: PlotStyle.PriceBox |
stroke |
A Stroke object used to construct the plot |
Tips: 1.We suggest using the NinjaScript wizard to generate your plots. 2.Plot objects DO NOT hold the actual script values. They simply define how the script's values are plotted on a chart. 3.A script may calculate multiple values and therefore hold multiple plots to determine the display of each calculated value. Script values are held in the script's Values collection. 4.If you script calls AddPlot() multiple times, then multiple Values series are added per the "three value series" example below 5.For MultiSeries scripts, plots are synched to the primary series of the NinjaScript object. 6.Plots will become visible once the script’s BarsRequiredToPlot value has been satisfied. By default, the value is 20. |
Indicator using various AddPlot() signatures |
---|
protected override void OnStateChange()
// Ensures that the width of the PlotStyle.Bar plot matches the width of the data series Plots[1].AutoWidth = true;
// Adds a blue Dash-Line style plot with 5pixel width and 50% opacity |
Indicator using a public Series<double> to expose a plot with a friendly name. This is required for making plots accessible in the Strategy BuilderFor an example on exposing other variables publicly, see Exposing Indicator values that are not plots |
---|
protected override void OnStateChange()
protected override void OnBarUpdate() MyPlot[1] = Close[0] + High[0] / 2;
[Browsable(false)]
[Browsable(false)] |
Indicator which adds three value series |
---|
protected override void OnStateChange() |
Indicator which dynamically adds a plot in State.Configure |
---|
protected override void OnStateChange() |