method 2: declare Series<double> using AddPlot and at #region Properties
As shown on the code (saved from built-in CandleStickPattern indicator) below, both method 1 and method 2 provide the intended functions. However, for the method 1 implementation, if this indicator is loaded on a chart and saving the chart template ("Saved As Default"), the indicator properties are not saved in the Default chart template. Charts opened in subsequent new tabs will not load this indicator. Reloading the Default template does not resolve the problem. Saving the chart template to a different name does not resolve the problem.
With the method 2 implementation, the indicator properties are saved in the Default (or other name) chart template. Charts opened in subsequent new tabs load this indicator correctly.
Is the method 1 implementation wrong? Is there a way to declare a public Series<double> without using AddPlot?
// method 1: declare Series without AddPlot
public Series<double> Price_Hi;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDe scriptionCandlestickPattern;
Name = "kcCandleStickPattern";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DrawOnPricePanel = true;
DisplayInDataBox = false;
IsAutoScale = false;
PaintPriceMarkers = false;
TrendStrength = 4;
Isignal_Validate = true;
AddPlot(Brushes.Transparent, NinjaTrader.Custom.Resource.CandlestickPatternFoun d);
// method 2: declare Series using AddPlot and at #region Properties
AddPlot(Brushes.Transparent, "Price_Hi");
// method 1: declare Series without AddPlot
Price_Hi = new Series<double>(this, MaximumBarsLookBack.Infinite);
}
else if (State == State.Configure)
{
... ;
}
else if (State == State.DataLoaded)
{
... ;
}
}
Comment