AddPlot()
AddPlot()
Definition
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.
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.
Methods and Properties
Syntax
AddPlot(Brush brush, string name)
AddPlot(Stroke stroke, PlotStyle plotStyle, string name)
This method should ONLY be called within the OnStateChange() method during State.SetDefaults or State.Configure
Parameters
- We suggest using the NinjaScript wizard to generate your plots.
- Plot objects DO NOT hold the actual script values. They simply define how the script’s values are plotted on a chart.
- 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.
- If you script calls AddPlot() multiple times, then multiple Values series are added per the “three value series” example below
- For MultiSeries scripts, plots are synched to the primary series of the NinjaScript object.
- Plots will become visible once the script’s BarsRequiredToPlot value has been satisfied. By default, the value is 20.
Examples
Indicator using various AddPlot() signatures
Indicator using a public Series\<double\> to expose a plot with a friendly name
This is required for making plots accessible in the strategy builder. For an example on exposing other variables publicly, see exposing indicator values that are not plots

