OPEN-SOURCE SCRIPT

Pivot Oscillator

259
█ OVERVIEW
Pivot Oscillator is a versatile oscillator that measures market strength by comparing the current price to local price pivots. Values are scaled by ATR, normalized to a 0–100 range, and displayed along with an SMA line.
Oscillator: generates signals suitable for pullback strategies.
SMA line: serves as a momentum indicator.

█ CONCEPTS
Pivot Oscillator is designed with dual functionality:
- Oscillator & signals: ideal for pullback strategies, detecting local highs/lows and short-term reversals.
- SMA (Momentum): shows stable market-side dominance and filters price impulses.

Calculation logic:
- Oscillator = closing price − pivot line (derived from average high/low pivots).
Scaled by ATR and normalized to 0–100:
50 – bullish dominance,
< 50 – bearish dominance.

SMA is computed from smoothed oscillator values and serves as a momentum indicator.

█ FEATURES
Pivot Calculation:
- Pivot Length (lenSwing) – the number of bars used to identify local pivots (highs/lows). Higher values filter only larger extremes, while lower values make the oscillator react faster to local highs and lows.
- Pivot Level (pivotLevel) – determines the position of the pivot line between the average low and high pivots. A value of 0.5 places the pivotLine exactly halfway between the average high and low pivots; values closer to 0 or 1 shift the line toward the low or high pivots, respectively.
- Pivot Lookback (lookback) – the number of recent pivots used to calculate the average pivot, which smooths the pivotLine and reduces noise caused by individual extremes.
- Oscillator calculation: closing price − pivotLine (average of pivots computed from the above parameters).

The pivotLine is then scaled by ATR and normalized to a 0–100 range.
ATR Scaling:
- ATR period (atrLen)
- Multipliers (multUp / multDown) for upper and lower scaling.

Dynamic Colors:
- Oscillator > 50 → green (bullish)
- Oscillator < 50 → red (bearish)

SMA Line (Momentum):
- Smoothed oscillator (SMA) serves as a momentum indicator.
- Dynamic color indicates direction of SMA.
- Helps identify dominant market side and trend.

Overbought / Oversold Zones:
- Configurable OB/OS levels for both oscillator and SMA.
- Dynamic band colors: change depending on SMA relative to maOverbought / maOversold.
- Provides visual confirmation for potential corrections or strong momentum.

Gradients & Visualization:
- Oscillator and SMA gradients (3 layers) with adjustable transparency.
- Gradient visualization for OB/OS zones and oscillator.
- Full customization of colors, line width, and transparency.

Signals:
- Oscillator leaving oversold zone → long signal
- Oscillator leaving overbought zone → short signal
- OB/OS band colors dynamically reflect SMA levels for additional confirmation.

Alerts:
- OB/OS cross alerts.

█ HOW TO USE
Add the indicator to your TradingView chart → Indicators → search for “Pivot Oscillator”.

Parameter Configuration:
- Pivot Settings: pivot length, pivot level, pivot lookback.
- ATR Settings: ATR period, scaling multipliers.
- Threshold Levels: OB/OS levels for oscillator and SMA.
- Signal Settings: SMA length, extra smoothing.
- Style Settings: bullish/bearish colors, OB/OS lines, midline, text colors.
- Gradient Settings: enable/disable gradients and transparency.

Signal Interpretation:
BUY (Long):
- Oscillator leaves the oversold zone (OS crossover).
- OB/OS band color may additionally confirm the signal when SMA < maOversold.

SELL (Short):
- Oscillator leaves the overbought zone (OB crossunder).
- OB/OS band color may additionally confirm the signal when SMA > maOverbought.

█ APPLICATIONS
Pivot Oscillator and SMA can be scaled for different strategies:
- Pullback strategies: oscillator detects local highs/lows.
- Momentum / Trend: SMA shows market-side dominance and trend direction.

Adjust pivot and ATR parameters:
- Lower settings: faster reaction, suitable for scalping or intraday trading.
- Higher settings: more stable readings, suitable for swing trading or longer timeframes.

█ NOTES
- In strong trends, the oscillator may remain in extreme zones for extended periods – reflects dominance, not necessarily a reversal.
- OB/OS levels should be adapted to the instrument and pivot/ATR settings.
- Works best when combined with other tools: support/resistance, market structure, and volume analysis.

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.