mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-17 10:08:05 +00:00
- Updated BBWN, BBWP, CCV, CV, CVI, EWMA, GKV, HLV, HV, Jvolty, JVOLTYN, MASSI, NATR, RSV, RV, RVI, TR, UI, VOV, VR, YZV indicators with documentation links. - Added documentation links for Aberration, Acceleration Bands, Andrews' Pitchfork, Adaptive Price Zone, ATR Bands, Bollinger Bands, Center of Gravity, Donchian Channels, Decay Min-Max Channel, Detrended Synthetic Price, EACP, EBSW, HOMOD, Jurik Volatility Bands, Keltner Channel, MA Envelope, Min-Max Channel, Price Channel, Regression Channels, Standard Deviation Channel, Stoller Average Range Channel, Super Trend Bands, Ultimate Bands, Ultimate Channel, VWAP Bands, and VWAP with Standard Deviation Bands.
48 lines
2.2 KiB
Plaintext
48 lines
2.2 KiB
Plaintext
// The MIT License (MIT)
|
||
// © mihakralj
|
||
//@version=6
|
||
indicator("Price Momentum Oscillator (PMO)", "PMO", overlay=false)
|
||
|
||
//@function Calculates Price Momentum Oscillator (DecisionPoint algorithm)
|
||
//@param src Source series to calculate PMO for
|
||
//@param time_periods First EMA smoothing period for 1-bar ROC (default 35)
|
||
//@param smooth_periods Second EMA smoothing period for PMO (default 20)
|
||
//@param signal_periods Signal line EMA period (default 10)
|
||
//@returns PMO value measuring double-smoothed momentum
|
||
pmo(series float src, simple int time_periods=35, simple int smooth_periods=20, simple int signal_periods=10)=>
|
||
if time_periods<2 or smooth_periods<=0 or signal_periods<=0
|
||
runtime.error("Periods must be greater than 0 (time_periods >= 2)")
|
||
// Step 1: Always 1-bar ROC (percentage)
|
||
float roc = bar_index > 0 and not na(src[1]) and src[1] != 0.0 ? (src / src[1] - 1.0) * 100.0 : 0.0
|
||
// Step 2: First Custom EMA of ROC (alpha = 2/time_periods), then ×10
|
||
float alpha1 = 2.0 / time_periods
|
||
var float roc_ema = na
|
||
roc_ema := na(roc_ema) ? roc : roc_ema + alpha1 * (roc - roc_ema)
|
||
float roc_ema_scaled = roc_ema * 10.0
|
||
// Step 3: Second Custom EMA of scaled RocEma (alpha = 2/smooth_periods) → PMO
|
||
float alpha2 = 2.0 / smooth_periods
|
||
var float pmo_val = na
|
||
pmo_val := na(pmo_val) ? roc_ema_scaled : pmo_val + alpha2 * (roc_ema_scaled - pmo_val)
|
||
pmo_val
|
||
|
||
// ---------- Main loop ----------
|
||
|
||
// Inputs
|
||
i_source = input.source(close, "Source")
|
||
i_time_periods = input.int(35, "Time Periods (1st EMA)", minval=2)
|
||
i_smooth_periods = input.int(20, "Smooth Periods (2nd EMA)", minval=1)
|
||
i_signal_periods = input.int(10, "Signal Line Period", minval=1)
|
||
|
||
// Calculation
|
||
pmo_value = pmo(i_source, i_time_periods, i_smooth_periods, i_signal_periods)
|
||
|
||
// Signal line uses standard EMA: alpha = 2/(N+1)
|
||
float alpha_signal = 2.0 / (i_signal_periods + 1)
|
||
var float signal_line = na
|
||
signal_line := na(signal_line) ? pmo_value : signal_line + alpha_signal * (pmo_value - signal_line)
|
||
|
||
// Plot
|
||
plot(pmo_value, "PMO", color=color.blue, linewidth=2)
|
||
plot(signal_line, "Signal", color=color.red, linewidth=2)
|
||
hline(0, "Zero", color=color.gray, linestyle=hline.style_dotted)
|