Failed to call method 'Initialize' for indicator 'SpreadValue': 'Add' method only accepts positive 'period' values, but was -1 Min
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.Line, "SPREAD"));
Add(SecondInstrument, BarsPeriods[0].Id, BarsPeriods[0].Value);
Overlay = false;
}
private double a,b,c,d,e=0;
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBarArray[0] > 0 && CurrentBarArray[1] > 0)
{
if (BarsInProgress > 0)
{
if(CurrentBars[0] ==1)
{
a = CurrentDayOHL(BarsArray[0]).CurrentOpen[0];
b = CurrentDayOHL(BarsArray[1]).CurrentOpen[0];
}
if( b > 0 && a >0)
{
c = (Closes[0][0]/a)-1;
d = (Closes[1][0]/b)-1;
e = (c - d)*50000;
}
SPREAD.Set(e);
}
}
}

Comment