Velocity / Acceleration

All functions · nseries package

AvgAcceleration

func (s Series) AvgAcceleration(length int, smoothLength int) Series

AvgAcceleration implements the acceleration component of Scott Cong’s Velocity And Acceleration indicator (as described in TASC September 2023).

The warm-up reads 0, not NaN: bars 0 to 2length-1 are 0 and the first valid index is 2length, the first bar whose lagged velocities are all past AvgVelocity’s warm-up. Releases before this change gave values from bar length, differenced against those warm-up zeros.

AvgVelocity

func (s Series) AvgVelocity(length int, smoothLength int) Series

AvgVelocity implements the velocity component of Scott Cong’s Velocity And Acceleration indicator (as described in TASC September 2023).

The warm-up reads 0, not NaN: bars 0 to length-1 are 0 and the first valid index is length. From bar length the velocity is smoothed with XAverage(smoothLength) as if the series started there: it passes the raw velocity through for smoothLength-1 bars and is then seeded with the simple average of its first smoothLength values. Releases before this change fed the warm-up zeros into the EMA’s seed, so the first values were too small (about half the velocity at smoothLength 3).