Files
QuanTAlib/lib/momentum/pmo/pmo.pine
T
Miha Kralj 75c6a9f135 Enhance validation tests for various indicators with external library comparisons
- Added detailed comments explaining the validation limitations for MMA and ZLEMA due to differences in algorithm implementations.
- Implemented validation tests for True Range against TALib and Tulip, ensuring directional agreement.
- Updated Ulcer Index validation to clarify differences in algorithmic approaches between QuanTAlib and Skender.
- Enhanced Ease of Movement tests to verify directional agreement with Tulip's EMV, noting differences in volume scaling.
- Expanded Klinger Volume Oscillator tests to validate against Skender and Tulip, focusing on directional agreement across multiple period configurations.
- Improved Negative Volume Index tests to compare percentage changes with Tulip, addressing differences in starting values.
- Updated Positive Volume Index tests to validate against Tulip, emphasizing percentage change comparisons.
- Enhanced Williams Accumulation/Distribution tests to verify directional agreement with Tulip, highlighting formula differences.
2026-02-11 14:46:56 -08:00

49 lines
2.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// The MIT License (MIT)
// © mihakralj
//@version=6
indicator("Price Momentum Oscillator (PMO)", "PMO", overlay=false)
//@function Calculates Price Momentum Oscillator (DecisionPoint algorithm)
//@doc https://github.com/mihakralj/pinescript/blob/main/indicators/momentum/pmo.md
//@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)