indicator · own pane · open source

Trend Quality Index

Deepwick · @deepwickv1Updated 2 Oct 2026▲ 0 users
Running…
Loading chart…

About

Trend Quality Index (TQI) — |close − SMA| divided by the standard deviation of close. Higher = price is far from its own mean (trending / stretched); lower = price is hugging the mean (ranging).

  • Use 1.5 as the 'overextended' stall to fade; 0.5 as the 'ranging' stall to breakout-trade.

Source code

//@version=5
indicator("Trend Quality Index", overlay=false)
len = input.int(20, "Length", minval=5, maxval=100)
tqi = math.abs(close - ta.sma(close, len)) / math.max(ta.stdev(close, len), 0.0001)
hline(1.5, "Stretched", color=color.gray)
hline(0.5, "Ranging", color=color.gray)
p_TQI = plot(tqi, "TQI", color=color.teal, linewidth=2)
alertcondition(ta.crossover(tqi, 1.5), "Overextended", "TQI crossed above 1.5 — overextended")
alertcondition(ta.crossunder(tqi, 0.5), "Squeezed", "TQI below 0.5 — ranging")

Comments

No comments yet.

Sign in to comment.