I'm trying to create a very simple chart(indicator) that shows the movement of spread price between 2 contracts. My code is below:
public class SpreadPrice : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "SpreadPrice";
Calculate = Calculate.OnBarClose;
IsOverlay = false;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
AddPlot(Brushes.Orange, "Spread");
Symbol = string.Empty;
}
else if (State == State.Configure)
{
AddDataSeries(Symbol);
}
}
protected override void OnBarUpdate()
{
if (CurrentBars[1] < 10)
return;
Value[0] = Closes[0][0] - Closes[1][0];
}
#region Properties
[Browsable(false)]
[XmlIgnore]
public Series<double> Spread
{
get { return Values[0]; }
}
[NinjaScriptProperty]
[Display(Name = "Symbol to Compare", Order = 1, GroupName = "Parameters")]
public string Symbol
{ get; set; }
#endregion
However, what I got is a zero line (screenshot attached).
Would you please help me understand why and how to fix it?
Thank you!

Comment