I then add the indicator to the T2017 chart and it works fine, giving me a running value between 0.0 and 1.0.
However, when I try to add the indicator to, say, the SPY chart, it indicator window is blank.
I have noticed this before on some other custom indicators I have constructed. Some will work with other instruments, other with just it's "root"
Am I missing a code line that allows it to be referenced by ALL instruments perhaps?
[Description("% Stocks Above 200 Day SMA")]
public class T2107indicator : Indicator
{
#region Variables
// Wizard generated variables
private double wordenInput1 = 1; // Default setting for WordenInput1
private int currentBars1 = -1;
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.SkyBlue), PlotStyle.Line, "Plot0"));
Overlay = false;
Add ("T2107", PeriodType.Day, 1);
t2107Series = new DataSeries(this);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if(CurrentBars[1] > currentBars1);
double AT2107 = BarsArray[1][0];
t2107Series.Set(AT2107);
Plot0.Set((t2107Series) [0]);
}
#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries Plot0
{
get { return Values[0]; }
}
[Description("")]
[GridCategory("Parameters")]
public double WordenInput1
{
get { return wordenInput1; }
set { wordenInput1 = Math.Max(1, value); }
}
private DataSeries t2107Series; // Declare a DataSeries variable
#endregion
Comment