Another version of the “stair step” representation of price moving within percentage variation of the Triangular moving average to draw the steps.
I add another simple MA to act like a signal for trend following identification. When the 2 lines are flat, market is ranging.
I believe it can be easily take part of trend following strategy of all sort.
//parameters :
//percent = 1 (daily)
//period = 100 (daily timeframe period of the triangular moving average
//SignalPeriod = 30
once ssMA = close
MA = TriangularAverage[period](close)
if(MA > ssMA + (MA/100)*percent) THEN
ssMA = MA
ELSIF (MA < ssMA - (MA/100)*percent) THEN
ssMA = MA
ELSE
ssMA = ssMA
ENDIF
signalLine = average[SignalPeriod](ssMA)
RETURN ssMA coloured(21,188,206), signalLine