OPEN-SOURCE SCRIPT

Fib Oscillator

138
What is Fib Oscillator and How to Use it?

🔶 1. Conceptual Overview

The Fib Oscillator is a Fibonacci-based relative position oscillator.
Instead of measuring momentum (like RSI or MACD), it measures where price currently sits between the recent swing high and swing low, expressed as a percentage within the Fibonacci range.

In other words:

It answers: “Where is price right now within its most recent dynamic range?”

It visualizes retracement and extension zones numerically, providing continuous feedback between 0% and 100% (and beyond if extended).

🔶 2. What the Script Does

The indicator:

Automatically detects recent high and low levels using an adaptive lookback window, which depends on ATR volatility.

Calculates the current price’s position between those levels as a percentage (0–100).

Plots that percentage as an oscillator — showing visually whether price is near the top, middle, or bottom of its recent range.

Overlays Fibonacci retracement levels (23.6%, 38.2%, 50%, 61.8%, 78.6%) as reference zones.

Generates alerts when the oscillator crosses key Fib thresholds — which can signal retracement completion, breakout potential, or pullback exhaustion.

🔶 3. Technical Flow Breakdown
(a) Inputs
Input Description Default Notes
atrLength ATR period used for volatility estimation 14 Used to dynamically tune lookback sensitivity
minLookback Minimum lookback window (candles) 20 Ensures stability even in low volatility
maxLookback Maximum lookback window 100 Limits over-expansion during high volatility
isInverse Inverts chart orientation false Useful for inverse markets (e.g. shorts or inverse BTC view)
(b) Volatility-Adaptive Lookback

Instead of using a fixed lookback, it calculates:

lookback
=
SMA(ATR,10)
/
SMA(Close,10)
×
500
lookback=SMA(ATR,10)/SMA(Close,10)×500

Then it clamps this between minLookback and maxLookback.

This makes the oscillator:

More reactive during high volatility (shorter lookback)

More stable during calm markets (longer lookback)

Essentially, it self-adjusts to market rhythm — you don’t have to constantly tweak lookback manually.

(c) High-Low Reference Points

It takes the highest and lowest points within the dynamic lookback window.

If isInverse = true, it flips the candle logic (useful if viewing inverse instruments like stablecoin pairs or when analyzing bearish setups invertedly).

(d) Oscillator Core

The main oscillator line:

osc
=
(
close

low
)
(
high

low
)
×
100
osc=
(high−low)
(close−low)


×100

0% = Price is at the lookback low.

100% = Price is at the lookback high.

50% = Midpoint (balanced).

Between Fibonacci percentages (23.6%, 38.2%, 61.8%, etc.), the oscillator indicates retracement stages.

(e) Fibonacci Levels as Reference

It overlays horizontal reference lines at:

0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, 100%


These act as support/resistance bands in oscillator space.

You can read it similar to how traders use Fibonacci retracements on charts, but compressed into a single line oscillator.

(f) Alerts

The script includes built-in alert conditions for crossovers at each major Fibonacci level.

You can set TradingView alerts such as:

“Oscillator crossed above 61.8%” → possible bullish continuation or breakout.

“Oscillator crossed below 38.2%” → possible pullback or correction starting.

This allows automated monitoring of fib retracement completions without manually drawing fib levels.

🔶 4. How to Use It
🔸 Visual Interpretation
Oscillator Value Zone Market Context
0–23.6% Deep Retracement Potential exhaustion of a down-move / early reversal
23.6–38.2% Shallow retracement zone Possible continuation phase
38.2–50% Mid retracement Neutral or indecisive structure
50–61.8% Key pivot region Common trend resumption zone
61.8–78.6% Late retracement Often “last pullback” area
78.6–100% Near high range Possible overextension / profit-taking
>100% Range breakout New leg formation / expansion
🔸 Practical Application Steps

Load the indicator on your chart (set overlay = false, so it’s below the main price chart).

Observe oscillator position relative to fib bands:

Use it to determine retracement depth.

Combine with structure tools:

Trend lines, swing points, or HTF market structure.

Use crossovers for timing:

Crossing above 61.8% in an uptrend often confirms breakout continuation.

Crossing below 38.2% in a downtrend signals renewed downside momentum.

For range markets, oscillator swings between 23.6% and 78.6% can define accumulation/distribution boundaries.

🔶 5. When to Use It

During Retracements: To gauge how deep the pullback has gone.

During Range Markets: To identify relative overbought/oversold positions.

Before Breakouts: Crossovers of 61.8% or 78.6% often precede impulsive moves.

In Multi-Timeframe Contexts:

LTF (15M–1H): Detect intraday retracement exhaustion.

HTF (4H–1D): Confirm major range expansions or key reversal zones.

🔶 6. Ideal Companion Indicators

The Fib Oscillator works best when contextualized with structure, volatility, and trend bias indicators.
Below are optimal pairings:

Companion Indicator Purpose Integration Insight
Market Structure MTF Tool Identify active trend direction Use Fib Oscillator only in trend direction for cleaner signals
EMA Ribbon / Supertrend Trend confirmation Align oscillator crossovers with EMA bias
ATR Bands / Volatility Envelope Validate breakout strength If oscillator >78.6% & ATR rising → valid breakout
Volume Oscillator Confirm retracement strength Volume contraction + oscillator under 38.2% → potential reversal
HTF Fib Retracement Tool Combine LTF oscillator with HTF fib confluence Powerful multi-timeframe setups
RSI or Stochastic Measure momentum relative to position RSI divergence while oscillator near 78.6% → exhaustion clue
🔶 7. Understanding the Settings
Setting Function Practical Impact
ATR Period (14) Controls volatility sampling Higher = smoother lookback adaptation
Min Lookback (20) Smallest window allowed Lower = more reactive but noisier
Max Lookback (100) Largest window allowed Higher = smoother but slower to react
Inverse Candle Chart Flips oscillator vertically Useful when analyzing bearish or inverse scenarios (e.g. short-side fib mapping)

Recommended Configs:

For scalping/intraday: ATR 10–14, lookback 20–50

For swing/position trading: ATR 14–21, lookback 50–100

🔶 8. Example Trade Logic (Practical Use)

Scenario: Uptrend on 4H chart

Oscillator drops to below 38.2% → retracement zone

Price consolidates → oscillator stabilizes

Oscillator crosses above 50% → pullback ending

Entry: Long when oscillator crosses above 61.8%

Exit: Near 78.6–100% zone or upon divergence with RSI

For Short Bias (Inverse Setup):
Enable isInverse = true to visually flip the oscillator (so lows become highs).
Use the same thresholds inversely.

🔶 9. Strengths & Limitations
✅ Strengths

Dynamic, self-adapting to volatility

Quantifies Fib retracement as a continuous function

Compact oscillator view (no clutter on chart)

Works well across all timeframes

Compatible with both trending and ranging markets

⚠️ Limitations

Doesn’t define trend direction — must be used with structure filters

Can whipsaw during choppy consolidations

The “lookback auto-adjust” may lag in sudden volatility shifts

Shouldn’t be used standalone for entries without structural confluence

🔶 10. Summary

The “Fib Oscillator” is a dynamic Fibonacci-relative positioning tool that merges retracement theory with adaptive volatility logic.
It gives traders an intuitive, quantified view of where price sits within its recent fib range, allowing anticipation of pullbacks, reversals, or breakout momentum.

Think of it as a "Fibonacci RSI", but instead of momentum strength, it shows positional depth — the vibrational location of price within its natural swing cycle.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.