Indicator Kalman Filter. It allows efficiently smoothing the noise, extracting the main trend from it.
This code is extracted from Average Filter Regression by laurenzo in PRC library and given signal according to the velocity. Go long if the velocity is above 0. Go short if the velocity is below 0.
// K = 500 ({1...2000})
Series = TotalPrice
ONCE Pred = Series
IF BarIndex = 0 THEN
KF = Series
ELSE
Smooth = Pred + (Series - Pred) * SQRT((K / 10000) * 2)
Velo = Velo + ((K / 10000) * (Series - Pred))
Pred = Smooth + Velo
KF = Pred
ENDIF
if velo > 0 then
g = 255
r = 0
else
g=0
r=255
endif
RETURN KF coloured(r,g,0) as "Kalman Filter" style (DOTTEDLINE4,3), Velo as "Velocity"