OPEN-SOURCE SCRIPT

Market Pressure Oscillator

87
█ OVERVIEW
The Market Pressure Oscillator is an advanced technical indicator for TradingView, enabling traders to identify potential trend reversals and momentum shifts through candle-based pressure analysis and divergence detection. It combines a smoothed oscillator with moving average signals, overbought/oversold levels, and divergence visualization, enhanced by customizable gradients, dynamic band colors, and alerts for quick decision-making.

█ CONCEPT
The indicator measures buying or selling pressure based on candle body size (open-to-close difference) and direction, with optional smoothing for clarity and divergence detection between price action and the oscillator. It relies solely on candle data, offering insights into trend strength, overbought/oversold conditions, and potential reversals with a customizable visual presentation.

█ WHY USE IT?
- Divergence Detection: Identifies bullish and bearish divergences to reinforce signals, especially near overbought/oversold zones.
- Candle Pressure Analysis: Measures pressure based on candle body size, normalized to a ±100 scale.
- Signal Generation: Provides buy/sell signals via overbought/oversold crossovers, zero-line crossovers, moving average zero-line crossovers, and dynamic band color changes.
- Visual Clarity: Uses dynamic colors, gradients, and fill layers for intuitive chart analysis.
Flexibility: Extensive settings allow customization to individual trading preferences.

█ HOW IT WORKS?
- Candle Pressure Calculation: Computes candle body size as math.abs(close - open), normalized against the average body size over a lookback period (avgBody = ta.sma(body, len)). - Candle direction (bullish: +1, bearish: -1, neutral: 0) is multiplied by body weight to derive pressure.
- Cumulative Pressure: Sums pressure values over the lookback period (Lookback Length) and normalizes to ±100 relative to the maximum possible value.
- Smoothing: Optionally applies EMA (Smoothing Length) to normalized pressure.
- Moving Average: Calculates SMA (Moving Average Length) for trend confirmation (Moving Average (SMA)).
- Divergence Detection: Identifies bullish/bearish divergences by comparing price and oscillator pivot highs/lows within a specified range (Pivot Length). Divergence signals appear with a delay equal to the Pivot Length.
- Signals: Generates signals for:
Crossing oversold upward (buy) or overbought downward (sell).
Crossing the zero line by the oscillator or moving average (buy/sell).
Bullish/bearish divergences, marked with labels, enhancing signals, especially near overbought/oversold zones.
Dynamic band color changes when the moving average crosses MA overbought/oversold thresholds (green for oversold, red for overbought).
- Visualization: Plots the oscillator and moving average with dynamic colors, gradient fills, transparent bands, and labels, with customizable overbought/oversold levels.
Alerts: Built-in alerts for divergences, overbought/oversold crossovers, and zero-line crossovers (oscillator and moving average).

█ SETTINGS AND CUSTOMIZATION
- Lookback Length: Period for aggregating candle pressure (default: 14).
- Smoothing Length (EMA): EMA length for smoothing the oscillator (default: 1). Higher values smooth the signal but may reduce signal frequency; adjust overbought/oversold levels accordingly.
- Moving Average Length (SMA): SMA length for the moving average (default: 14, minval=1). Higher values make SMA a trend indicator, requiring adjusted MA overbought/oversold levels.
- Pivot Length (Left/Right): Candles for detecting pivot highs/lows in divergence calculations (default: 2, minval=1). Higher values reduce noise but add delay equal to the set value.
- Enable Divergence Detection: Enables divergence detection (default: true).
- Overbought/Oversold Levels: Thresholds for the oscillator (default: 30/-30) and moving average (default: 10/-10). For the moving average, no arrows appear; bands change color from gray to green (oversold) or red (overbought), reinforcing entry signals.
- Signal Type: Select signals to display: "None", "Overbought/Oversold", "Zero Line", "MA Zero Line", "All" (default: "Overbought/Oversold").
- Colors and Gradients: Customize colors for bullish/bearish oscillator, moving average, zero line, overbought/oversold levels, and divergence labels.
- Transparency: Adjust gradient fill transparency (default: 70, minval=0, maxval=100) and band/label transparency (default: 40, minval=0, maxval=100) for consistent visuals.
- Visualizations: Enable/disable moving average, gradients for zero/overbought/oversold levels, and gradient fills.

█ USAGE EXAMPLES
- Momentum Analysis: Observe the MPO Oscillator above 0 for bullish momentum or below 0 for bearish momentum. The SMA, being smoother, reacts slower and can confirm trend direction as a noise filter.
- Reversal Signals: Look for buy triangles when the oscillator crosses oversold upward, especially when the SMA is below the MA oversold threshold and the band turns green. Similarly, seek sell triangles when crossing overbought downward, with the SMA above the MA overbought threshold and the band turning red.
- Using Divergences: Treat bullish (green labels) and bearish (red labels) divergences as reinforcement for other signals, especially near overbought/oversold zones, indicating stronger potential trend reversals.
- Customization: Adjust lookback length, smoothing, and moving average length to specific instruments and timeframes to minimize false signals.

█ USER NOTES
Combine the indicator with tools like Fibonacci levels or pivot points to enhance accuracy.
Test different settings for lookback length, smoothing, and moving average length on your chosen instrument and timeframe to find optimal values.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.