This code works fine for showing up-bar time lengths, but when I try to apply indicators to it, such as a 10 bar SMA, the SMA returns the SMA of price, not time.
I'm sure it's something simple, but I've been unable to solve. Many thanks.
protected override void OnBarUpdate()
{
if (CurrentBar<1)
return;
if (Close[0] < Open[0])
return;
DateTime eTime, pTime;
if (Bars.FirstBarOfSession)
Bars.Session.GetNextBeginEnd(Time[0],out pTime,out eTime);
else
pTime = Time[1];
TimeSpan span = Time[0].Subtract(pTime);
TimePast.Set(span.TotalMinutes);
}
Comment