← Script Marketplace
Open-source scriptindicator/v1

Detrended Price Oscillator

by Kodexius·@kodexius·

Remove a displaced moving average from price to emphasize shorter-term cycles.

#cycle#dpo#oscillator
Detrended Price Oscillator chart preview

Description

The Detrended Price Oscillator compares current price with a moving average shifted back by roughly half its length. Removing the longer trend component can make intermediate peaks, troughs, and recurring cycles easier to examine.

Open-source script. Everyone can inspect the source code, use the script on a chart, and save an editable copy.

Release notes

Version history · 1 published version

Version 1CurrentChart updatedDetrended Price Oscillator · Aug 31, 2026
Release notes

Initial classic indicator release.

View current source ↓
Source codempl-2.0View source

indicator("Detrended Price Oscillator", { overlay: false });
const length = input.int("Length", 21, { min: 2, max: 500 });
const source = input.source("Source", "close");
const basis = sma(source, length);
const shift = Math.floor(length / 2) + 1;
const line = source.map((_, i) => i < shift ? NaN : source[i - shift] - basis[i]);
plot(line, { title: "DPO", color: "#00bcd4", lineWidth: 2 });
hline(0, { title: "Zero", color: "#78909c", style: "dotted" });
  

Community discussion

0 comments

Loading…

No comments yet. Start the discussion.