indicator · own pane · open source

Detrended Price

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

About

Detrended Price (DPO) removes the trend from price by subtracting the SMA shifted forward by half the lookback. Shows short-term cycles around the trend.

  • Zero-line crosses flag short-term momentum shifts.
  • Peaks above zero and troughs below zero identify cycle extremes.
  • Use on equities/indices with clear cyclical behaviour.

Source code

//@version=5
indicator("Detrended Price", overlay=false)
len = input.int(20, "Length", minval=2, maxval=200)
src = input.source("close", "Source")
dp = src - ta.sma(src, len)[math.floor(len / 2)]
hline(0, "Zero", color=color.gray, linestyle=hline.style_dotted)
p_DPO = plot(dp, "DPO", color=dp >= 0 ? color.teal : color.red, style=plot.style_columns)
alertcondition(ta.crossover(dp, 0), "DPO crosses zero up", "Detrended price crossed above zero")
alertcondition(ta.crossunder(dp, 0), "DPO crosses zero down", "Detrended price crossed below zero")

Comments

No comments yet.

Sign in to comment.