PROTECTED SOURCE SCRIPT

Auto Fibonacci Retracements with Alerts [SwissAlgo]

51
AUTO-FIBONACCI RETRACEMENT: LEVELS, ALERTS & PD ZONES
Automatically maps Fibonacci retracement levels with Premium/Discount (PD) zones and configurable alerts for technical analysis study.
------------------------------------------------------------------
FEATURES
Automatic Fibonacci Levels Detection
  • Identifies swing extremes (reference high and low to map retracements) from a user-defined trend start date and trend indication automatically
  • Calculates 20 Fibonacci levels (from -2.618 to +2.618) automatically
  • Dynamically updates Fib levels as price action develops, anchoring the bottom (in case of uptrends) or the top (in case of downtrends)
  • Detects potential Trend's Change of Character automatically
  • Premium/Discount (PD) zone visualization based on trend and price extremes

Visual Components
  • Dotted horizontal lines for each Fibonacci level
  • 'Premium' and 'discount' zone highlighting
  • Change of Character (CHoCH) marker when a trend anchor breaks (a bottom is broken after an uptrend, a top is broken after a downtrend)
  • Adaptive label colors for light/dark chart themes

Alert System
  • Configurable alerts for all Fibonacci levels
  • Requires 2 consecutive bar closes for confirmation (reduces false signals)
  • CHoCH alert when a locked extreme is broken
  • Set up using "Any alert() function call" option

------------------------------------------------------------------
USE CASES

Two Primary Use Cases:

1. PROSPECTIVE TREND MAPPING (Real-Time Tracking)
Set start date at or just before an anticipated swing extreme to track levels as the trend develops:
  • For Uptrend: Place start date near a bottom. The bottom level locks after consolidation, while the top updates in real-time as the price climbs higher
  • For Downtrend: Place start date near a top. The top-level locks after consolidation, while the bottom updates in real-time as the price falls lower

This mode tracks developing price action against Fibonacci levels as the swing unfolds.

2. RETROSPECTIVE ANALYSIS (Historical Swing Study)
Set the start date at a completed swing extreme to analyze how the price interacted (and is interacting) with the Fibonacci levels:
  • Both high and low are already established in the historical data
  • Levels remain static for analysis purposes
  • Useful for analyzing price behavior relative to Fibonacci levels, studying retracement dynamics, and assessing a trading posture

------------------------------------------------------------------
HOW TO USE
  • Set 'Start Date': Select Start Date (anchor point) at or just before the swing extreme (bottom for uptrend, top for downtrend)
  • Choose Trend Direction (Up or Down): direction is known for retrospective analysis, uncertain for prospective analysis
  • Update the start date when significant structure breaks occur to begin analyzing a new swing cycle.
  • Configure alerts as needed for your analysis

------------------------------------------------------------------
TECHNICAL DETAILS

♦ Auto-Mapped Fibonacci Retracement Levels:
2.618, 2.000, 1.618, 1.414, 1.272, 1.000, 0.882, 0.786, 0.618, 0.500, 0.382, 0.236, 0.118, 0.000, -0.272, -0.618, -1.000, -1.618, -2.000, -2.618
♦ Premium/Discount (PD) Zones:
  • Uptrend: Green (discount zone) = levels 0 to 0.5 | Red (premium zone) = levels 0.5 to 1.0
  • Downtrend: Red (premium zone) = levels 0 to 0.5 | Green (discount zone) = levels 0.5 to 1.0
  • The yellow line represents the 0.5 equilibrium level

♦ Lock Mechanism:
The indicator monitors for new extremes to detect a Change of Character in the trend (providing visual feedback and alerts). It locks the anchor swing extreme after a timeframe-appropriate consolidation period has elapsed (varies from 200 bars on second charts to 1 bar on monthly charts) to detect such potentially critical events.
------------------------------------------------------------------

IMPORTANT NOTES
This is an educational tool for technical analysis study. It displays historical and current price relationships to Fibonacci levels but does not predict future price movements or provide trading recommendations.
DISCLAIMER: This indicator is for educational and informational purposes only. It does not constitute financial advice or trading signals. Past price patterns do not guarantee future results. Trading involves substantial risk of loss. Always conduct your own analysis and consult with qualified financial professionals before making trading decisions. By using this indicator, you acknowledge and agree to these limitations.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.