OPEN-SOURCE SCRIPT
Adaptive Fibonacci Compass [JOAT]

Adaptive Fibonacci Compass [JOAT]
Overview
Adaptive Fibonacci Compass is a dynamic, pivot-anchored Fibonacci retracement and extension system built in Pine Script v6. It continuously detects the most recent confirmed swing pivot pair, grades the pivot's ATR-normalised strength, checks for Break of Structure or Change of Character on the swing axis, then draws a live Fibonacci grid of seven standard levels (0, 0.236, 0.382, 0.5, 0.618, 0.786, 1.0) with fill-highlighted Optimal Trade Entry zones (OTE: 0.382–0.618 and 0.618–0.786) — all rendered at barstate.islast using the delete-before-create pattern for zero ghost-drawing artifacts.

Why Adaptive Fibonacci?
Static Fibonacci tools require manual anchor selection, which introduces subjectivity and results in different traders drawing the same move differently. Adaptive Fibonacci Compass removes this ambiguity by algorithmically detecting the pivot pair that defines the most recent significant swing and anchoring the grid there automatically. The grid updates whenever a new, stronger pivot forms — keeping the Fibonacci reference aligned with the current market structure without any manual intervention.
Pivot Detection and ATR Strength Grading
Swing pivots are detected using ta.pivothigh() and ta.pivotlow() with configurable left and right bar confirmation windows (default 10/10). When a new pivot forms, its ATR-normalised strength is computed:
Strength = (pivotHigh - pivotLow) / ATR(14)
This ratio grades the swing on a universal scale independent of price level or instrument. Pivots grading above a configurable minimum strength (default 1.5 ATR) are accepted as valid Fibonacci anchors. Smaller price structures that do not meet the threshold are ignored, preventing the grid from anchoring to noise.
BOS / CHoCH Detection on Pivot Axis
Each time a new pivot pair is accepted, the engine checks whether the new swing extreme exceeds the prior swing extreme of the same type:
- BOS Up: New swing high exceeds the previous swing high — structural expansion to the upside
- BOS Down: New swing low is below the previous swing low — structural expansion to the downside
- CHoCH: A swing extreme that forms against the prevailing structure — e.g., a new swing high forming when prior context was bearish
BOS and CHoCH labels are stamped at the pivot level to provide structural context for interpreting the Fibonacci grid.
Dynamic Fibonacci Grid (7 Levels)
The grid spans from the last confirmed swing low to the last confirmed swing high (for bullish pivots) or the reverse (for bearish pivots). Seven retracement levels are drawn as horizontal lines:
- 0.0 (swing origin) — white/neutral
- 0.236 — subtle grey
- 0.382 — teal (start of OTE zone)
- 0.5 — gold (midpoint)
- 0.618 — teal (end of deep OTE zone)
- 0.786 — purple
- 1.0 (swing extreme) — white/neutral
Each level label shows both the ratio and the exact price value.
Optimal Trade Entry (OTE) Fill Zones
Two fill zones are highlighted as semi-transparent boxes between specific Fibonacci levels, representing the confluence areas where institutional entries are statistically most concentrated:
- OTE 0.382–0.618: The standard OTE zone — the area of highest probability for pullback continuation trades
- OTE 0.618–0.786: The deep OTE zone — commonly used for higher-conviction reversal entries where the move has retraced deeply into the prior swing
Both zones are rendered with directional colour (teal for bullish swings, red for bearish swings) at 80–85% transparency.
Live Pivot Tracking and Grid Refresh
On every bar, the indicator tracks whether price is forming a new potential extreme beyond the current grid's anchor. When a new confirmed pivot qualifies (passes the ATR strength threshold), the previous grid is fully deleted (all lines, labels, and boxes) and rebuilt from the new anchor points. The delete-before-create pattern at barstate.islast ensures no duplicate or orphaned drawing objects accumulate over the session.
Inputs Reference
- Pivot Left Bars (10) — left confirmation bars for swing detection
- Pivot Right Bars (10) — right confirmation bars for swing detection
- Min ATR Strength (1.5) — minimum swing size in ATR units to accept as a valid anchor
- Show Fib Grid — toggles the full Fibonacci grid
- Show OTE Zones — toggles the 0.382–0.618 and 0.618–0.786 fill zones
- Show BOS / CHoCH Labels — toggles structural labels on pivot extremes
- Show Level Labels — toggles price and ratio annotations on each Fibonacci line
- Extend Lines (bars, default 30) — how far right the grid lines extend from the current bar
- Theme: Dark, Light, Auto
How to Use
1. Apply to any liquid market on any timeframe. The indicator needs at least (PivotLeft + PivotRight) * 3 bars to warm up.
2. The gold 0.5 level and teal 0.382/0.618 lines define the primary trade management area. In a confirmed uptrend, look for price to pull back into the OTE 0.382–0.618 zone with a bullish reaction for long entries.
3. The deep OTE 0.618–0.786 zone is valid for entries only in strong, high-momentum swings where the pullback is orderly and accompanied by decreasing volume.
4. Treat the 0.0 and 1.0 levels as structural extremes. A confirmed close beyond the 1.0 level triggers a new BOS and should cause the grid to reload on the next qualifying pivot.
5. Use BOS labels to confirm that the current Fibonacci swing direction aligns with the broader structural bias from a higher timeframe.
Non-Repainting Design
Pivots are only detected once the full right-bar confirmation period has elapsed. The grid is always anchored to confirmed historical pivots. No drawing is created based on the current in-progress bar. All grid refreshes occur at barstate.islast using confirmed pivot data.
Limitations
- The indicator anchors to the most recent qualifying pivot pair. In multi-week trends with no significant retracement, the grid may anchor to a very old pivot that is no longer contextually relevant.
- The minimum ATR strength filter helps but does not eliminate all noise pivots on highly volatile instruments. Increasing the threshold on crypto assets is recommended.
- Fibonacci levels are probabilistic reference zones, not guaranteed reversal or support/resistance levels. Confluence with other structure (OBs, PDH/PDL, volume profile POC) significantly increases their reliability.
- The grid does not account for higher-timeframe Fibonacci structures. Always check alignment with HTF pivots manually.
Disclaimer
This indicator is for educational and informational purposes only. Fibonacci retracements are historical price relationships and do not predict future market behaviour with certainty. Always use proper risk management and conduct your own analysis.
Made with passion by officialjackofalltrades
Overview
Adaptive Fibonacci Compass is a dynamic, pivot-anchored Fibonacci retracement and extension system built in Pine Script v6. It continuously detects the most recent confirmed swing pivot pair, grades the pivot's ATR-normalised strength, checks for Break of Structure or Change of Character on the swing axis, then draws a live Fibonacci grid of seven standard levels (0, 0.236, 0.382, 0.5, 0.618, 0.786, 1.0) with fill-highlighted Optimal Trade Entry zones (OTE: 0.382–0.618 and 0.618–0.786) — all rendered at barstate.islast using the delete-before-create pattern for zero ghost-drawing artifacts.
Why Adaptive Fibonacci?
Static Fibonacci tools require manual anchor selection, which introduces subjectivity and results in different traders drawing the same move differently. Adaptive Fibonacci Compass removes this ambiguity by algorithmically detecting the pivot pair that defines the most recent significant swing and anchoring the grid there automatically. The grid updates whenever a new, stronger pivot forms — keeping the Fibonacci reference aligned with the current market structure without any manual intervention.
Pivot Detection and ATR Strength Grading
Swing pivots are detected using ta.pivothigh() and ta.pivotlow() with configurable left and right bar confirmation windows (default 10/10). When a new pivot forms, its ATR-normalised strength is computed:
Strength = (pivotHigh - pivotLow) / ATR(14)
This ratio grades the swing on a universal scale independent of price level or instrument. Pivots grading above a configurable minimum strength (default 1.5 ATR) are accepted as valid Fibonacci anchors. Smaller price structures that do not meet the threshold are ignored, preventing the grid from anchoring to noise.
BOS / CHoCH Detection on Pivot Axis
Each time a new pivot pair is accepted, the engine checks whether the new swing extreme exceeds the prior swing extreme of the same type:
- BOS Up: New swing high exceeds the previous swing high — structural expansion to the upside
- BOS Down: New swing low is below the previous swing low — structural expansion to the downside
- CHoCH: A swing extreme that forms against the prevailing structure — e.g., a new swing high forming when prior context was bearish
BOS and CHoCH labels are stamped at the pivot level to provide structural context for interpreting the Fibonacci grid.
Dynamic Fibonacci Grid (7 Levels)
The grid spans from the last confirmed swing low to the last confirmed swing high (for bullish pivots) or the reverse (for bearish pivots). Seven retracement levels are drawn as horizontal lines:
- 0.0 (swing origin) — white/neutral
- 0.236 — subtle grey
- 0.382 — teal (start of OTE zone)
- 0.5 — gold (midpoint)
- 0.618 — teal (end of deep OTE zone)
- 0.786 — purple
- 1.0 (swing extreme) — white/neutral
Each level label shows both the ratio and the exact price value.
Optimal Trade Entry (OTE) Fill Zones
Two fill zones are highlighted as semi-transparent boxes between specific Fibonacci levels, representing the confluence areas where institutional entries are statistically most concentrated:
- OTE 0.382–0.618: The standard OTE zone — the area of highest probability for pullback continuation trades
- OTE 0.618–0.786: The deep OTE zone — commonly used for higher-conviction reversal entries where the move has retraced deeply into the prior swing
Both zones are rendered with directional colour (teal for bullish swings, red for bearish swings) at 80–85% transparency.
Live Pivot Tracking and Grid Refresh
On every bar, the indicator tracks whether price is forming a new potential extreme beyond the current grid's anchor. When a new confirmed pivot qualifies (passes the ATR strength threshold), the previous grid is fully deleted (all lines, labels, and boxes) and rebuilt from the new anchor points. The delete-before-create pattern at barstate.islast ensures no duplicate or orphaned drawing objects accumulate over the session.
Inputs Reference
- Pivot Left Bars (10) — left confirmation bars for swing detection
- Pivot Right Bars (10) — right confirmation bars for swing detection
- Min ATR Strength (1.5) — minimum swing size in ATR units to accept as a valid anchor
- Show Fib Grid — toggles the full Fibonacci grid
- Show OTE Zones — toggles the 0.382–0.618 and 0.618–0.786 fill zones
- Show BOS / CHoCH Labels — toggles structural labels on pivot extremes
- Show Level Labels — toggles price and ratio annotations on each Fibonacci line
- Extend Lines (bars, default 30) — how far right the grid lines extend from the current bar
- Theme: Dark, Light, Auto
How to Use
1. Apply to any liquid market on any timeframe. The indicator needs at least (PivotLeft + PivotRight) * 3 bars to warm up.
2. The gold 0.5 level and teal 0.382/0.618 lines define the primary trade management area. In a confirmed uptrend, look for price to pull back into the OTE 0.382–0.618 zone with a bullish reaction for long entries.
3. The deep OTE 0.618–0.786 zone is valid for entries only in strong, high-momentum swings where the pullback is orderly and accompanied by decreasing volume.
4. Treat the 0.0 and 1.0 levels as structural extremes. A confirmed close beyond the 1.0 level triggers a new BOS and should cause the grid to reload on the next qualifying pivot.
5. Use BOS labels to confirm that the current Fibonacci swing direction aligns with the broader structural bias from a higher timeframe.
Non-Repainting Design
Pivots are only detected once the full right-bar confirmation period has elapsed. The grid is always anchored to confirmed historical pivots. No drawing is created based on the current in-progress bar. All grid refreshes occur at barstate.islast using confirmed pivot data.
Limitations
- The indicator anchors to the most recent qualifying pivot pair. In multi-week trends with no significant retracement, the grid may anchor to a very old pivot that is no longer contextually relevant.
- The minimum ATR strength filter helps but does not eliminate all noise pivots on highly volatile instruments. Increasing the threshold on crypto assets is recommended.
- Fibonacci levels are probabilistic reference zones, not guaranteed reversal or support/resistance levels. Confluence with other structure (OBs, PDH/PDL, volume profile POC) significantly increases their reliability.
- The grid does not account for higher-timeframe Fibonacci structures. Always check alignment with HTF pivots manually.
Disclaimer
This indicator is for educational and informational purposes only. Fibonacci retracements are historical price relationships and do not predict future market behaviour with certainty. Always use proper risk management and conduct your own analysis.
Made with passion by officialjackofalltrades
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。