This indicator calculates the Detrended Price Oscillator (DPO) and applies Hull Moving Average (HMA) and Exponential Moving Average (EMA) smoothing to it.
1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
76 lines of Pine Script v4 from ARI-DPO.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.
ARI-DPO.pine
//@version=4
study(title=" ARI-DPO 2.0", shorttitle="ARI-DT2", format=format.price, precision=2, resolution="")
// Input parameters
period_ = input(21, title="Period", minval=1)
trendperiod_ = input(200, title="Trend Period", minval=7)
rsilength = input(14, title="RSI Length", minval=1)
drawLines = input(false, title="Draw Lines")
drawIndicator = input(true, title="Draw Indicator")
// Calculate DPO
barsback = period_/2 + 1
formula = close
ma = sma(formula, period_)
dpo = formula - ma[barsback]
// Calculate HMA and EMA
hma = hma(dpo, trendperiod_)
ema = ema(dpo, trendperiod_)
// Calculate RSI
rsi = rsi(dpo, rsilength)
rsiclose = rsi(close, rsilength)
// Function to determine line color
color_lines(line, fast, slow) =>
linecolor = color.white
if line > fast and fast > slow
linecolor := color.teal
if line > slow and slow > fast
linecolor := color.green
if fast > line and line > slow
linecolor := color.orange
if slow > line and line > fast
linecolor := color.yellow
if line < slow and slow < fast
linecolor := color.red
if line < fast and fast < slow
linecolor := color.purple
linecolor
// Determine line color
linecolor = color_lines(dpo, hma, ema)
// Determine RSI color
rsicolor = color.white
rsifunc = rsiclose
if rsifunc > 50
rsicolor := color.yellow
if rsifunc > 60
rsicolor := color.orange
if rsifunc > 70
rsicolor := color.red
if rsifunc > 80
rsicolor := color.purple
if rsifunc < 20
rsicolor := color.teal
if rsifunc < 30
rsicolor := color.green
if rsifunc < 40
rsicolor := color.lime
if rsifunc < 50
rsicolor := color.yellow
// Plotting
plot(drawIndicator ? line : na, offset = 0, title="ema(DPO)", color=linecolor, linewidth=3)
plot(drawLines ? dpo : na, color=rsicolor, linewidth=2)
plot(drawLines ? hma : na, color=color.blue, linewidth=1)
plot(drawLines ? ema : na, color=color.red, linewidth=1)
plotchar(drawIndicator ? (linecolor != color.teal and linecolor[1] == color.teal) : na, na, char="⬇", location=location.top, color=color.purple, size=size.tiny, transp=0)
plotchar(drawIndicator ? (linecolor != color.teal and linecolor != color.green and linecolor[1] == color.green and linecolor[2] == color.green) : na, na, char="⬇", location=location.top, color=color.red, size=size.tiny, transp=0)
plotchar(drawIndicator ? (linecolor == color.green and linecolor[1] != color.green and linecolor[2] != color.green) : na, na, char="⬆", location=location.bottom, color=color.green, size=size.tiny, transp=0)
plotchar(drawIndicator ? (linecolor == color.teal and linecolor[1] != color.green and linecolor[1] != color.teal and linecolor[2] != color.teal) : na, na, char="⬆", location=location.bottom, color=color.teal, size=size.tiny, transp=0)
plotchar(drawLines ? 1 : na, na, char="|", location=location.bottom, color=linecolor, size=size.tiny, transp=0)
Overview
ARI-DPO 2.0 also evaluates Relative Strength Index (RSI) levels. The script determines market state by comparing the DPO to its trend averages, dynamically color-coding the plotted values and printing arrow characters to indicate state transitions. Inputs control the calculation periods for the DPO, moving averages, and RSI, along with visibility toggles for the lines. It draws in a separate indicator pane.
Detrended Price Oscillator calculation
Hull and Exponential moving average smoothing on DPO
RSI calculation for overbought and oversold coloring
Directional transition signals with arrow plots
Configurable display toggles for lines and indicator elements
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Period
int
21
period_
Trend Period
int
200
trendperiod_
RSI Length
int
14
rsilength
Draw Lines
bool
false
drawLines
Draw Indicator
bool
true
drawIndicator
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
The Derivative Oscillator calculates a double-exponentially smoothed Relative Strength Index (RSI) and subtracts its Simple Moving Average (SMA) to form the main oscillator line. A secondary signal line is plotted using an SMA of the main oscillator values. Th
This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome
This indicator calculates and plots the standard Moving Average Convergence Divergence oscillator in a separate pane. It computes the difference between a fast and slow moving average, derives a signal line through smoothing, and plots a histogram representing
MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us
Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m
KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev