I successfully implemented custom indicator logic to allow a user to select a price series which then causes associated information to be displayed within the NinjaScript Output window. The code I used is based on the following pseudo code modeled after code I obtained from your support portal:
[NinjaScriptProperty]
[PropertyEditor("NinjaTrader.Gui.Tools.InputEditor" )]
[Display(Name = "Price Series", Description = "Price Series", Prompt = "Edit...", Order = 00, GroupName = TestGroupName)]
[XmlIgnore]
public ISeries<double> PriceSeries
{ ... }
[Browsable(false)]
public string PriceSeriesSerialize
{
get
{
return (PriceSeries != null && PriceSeries.GetType() == typeof(PriceSeries)) ? (PriceSeries as PriceSeries).PriceType.ToString() : null;
}
set
{
PriceSeries = new ISeries<double>[7] { Close, High, Low, Median, Open, Typical, Weighted }.Where(se => (se as PriceSeries).PriceType.ToString() == value).First();
}
}
Within State.DataLoaded:
// If a price series is not selected, set to null to prevent use
if (PriceSeries != null && PriceSeries.GetType() != typeof(PriceSeries))
PriceSeries = null;
if (PriceSeries != null)
Print("Price Series Name: " + PriceSeriesSerialize);
I'm now trying to implement the same pattern of code however for a user selected plot series (e.g. for the RSI indicator's Avg plot series). I'd like to output the name of the user selected plot series name (e.g. Avg) however I'm not sure about the casting check to use (e.g. PlotSeries.GetType() != typeof(Series<double>)) nor sure of what logic to implement within a PlotSeriesSerialize serializer method. Phrased a different way, I'm trying to obtain the series name that is displayed at the end of the InputEditor UI component (e.g. "RSI(SPY (1 Minute), 14, 3).Avg"), specifically its trailing "Avg" text).
Can you help? Below is some code that doesn't work that I'm hopeful you can help with.
[NinjaScriptProperty]
[PropertyEditor("NinjaTrader.Gui.Tools.InputEditor" )]
[Display(Name = "Plot Series", Description = "Plot Series", Prompt = "Edit...", Order = 01, GroupName = TestGroupName)]
[XmlIgnore]
public ISeries<double> PlotSeries
{ ... }
[Browsable(false)]
public string PlotSeriesSerialize
{ ? }
Within State.DataLoaded:
// If a plot series is not selected, set to null to prevent use
if (PlotSeries != null && PlotSeries.GetType() != typeof(Series<double>))
PlotSeries = null;
if (PlotSeries != null)
Print("Plot Series Name: " + PlotSeriesSerialize);
Thanks!

Comment