OPEN-SOURCE SCRIPT
Auto Fibonacci Retracement [identityKa]

Overview
The Auto Fibonacci Retracement [identityKa] is a dynamic structural mapping tool designed to automate the process of drawing Fibonacci levels. By continually scanning historical price action over a user-defined lookback period, the script identifies the dominant macroeconomic Swing High and Swing Low. It then mathematically constructs the retracement zones in real-time, completely removing human subjectivity from technical analysis.
Core Mathematical Engine
The script utilizes the ta.highest and ta.lowest functions coupled with a structural array system to ensure flawless historical anchoring:
Trend Directionality: The script determines the current macro trend by calculating the chronological offset between the absolute High and absolute Low. If the Low occurred chronologically before the High, it establishes a Bullish bias and draws the Fibonacci ratios from bottom to top. Conversely, it draws from top to bottom for a Bearish bias.
Level Generation: Utilizing standard percentage retracements, the engine strictly plots the 0.382, 0.500 (Equilibrium), 0.618 (Golden Pocket), and 0.786 (Deep Retracement) levels. The lines are drawn using a smart array management system that clears old lines and strictly plots the active data on the live bar to prevent chart lag and clutter.
HUD Dashboard & AI Logic
To assist in reading the Fibonacci zones, an integrated on-chart panel evaluates the relationship between the live closing price and the drawn retracement levels:
Dangerous: Displayed whenever the current price enters the zone between the 0.382 and the 0.618 (Golden Pocket) levels. This area represents deep institutional retracement and is mathematically the highest-risk zone for trend-continuation entries, as the market is actively deciding whether to bounce or reverse.
LONG / SHORT: The engine defaults to the macro trend direction ("LONG" in an uptrend, "SHORT" in a downtrend) as long as the price remains confidently outside the deep retracement zone (e.g., above the 0.382 in a bullish trend), signifying that the primary momentum remains intact. If the deep 0.786 level is broken against the trend, the script will mathematically flip the bias, assuming a structural reversal.
How to Use It
Traders should use this script to automate their top-down analysis. Rather than manually redrawing Fibonacci levels as new highs or lows are made, this indicator updates dynamically. During an established trend, traders should look for the AI Suggestion to switch to "Dangerous" (indicating price has entered the Golden Pocket) and await a definitive candlestick rejection pattern off the 0.500 or 0.618 level before re-entering the market in the direction of the macro trend.
The Auto Fibonacci Retracement [identityKa] is a dynamic structural mapping tool designed to automate the process of drawing Fibonacci levels. By continually scanning historical price action over a user-defined lookback period, the script identifies the dominant macroeconomic Swing High and Swing Low. It then mathematically constructs the retracement zones in real-time, completely removing human subjectivity from technical analysis.
Core Mathematical Engine
The script utilizes the ta.highest and ta.lowest functions coupled with a structural array system to ensure flawless historical anchoring:
Trend Directionality: The script determines the current macro trend by calculating the chronological offset between the absolute High and absolute Low. If the Low occurred chronologically before the High, it establishes a Bullish bias and draws the Fibonacci ratios from bottom to top. Conversely, it draws from top to bottom for a Bearish bias.
Level Generation: Utilizing standard percentage retracements, the engine strictly plots the 0.382, 0.500 (Equilibrium), 0.618 (Golden Pocket), and 0.786 (Deep Retracement) levels. The lines are drawn using a smart array management system that clears old lines and strictly plots the active data on the live bar to prevent chart lag and clutter.
HUD Dashboard & AI Logic
To assist in reading the Fibonacci zones, an integrated on-chart panel evaluates the relationship between the live closing price and the drawn retracement levels:
Dangerous: Displayed whenever the current price enters the zone between the 0.382 and the 0.618 (Golden Pocket) levels. This area represents deep institutional retracement and is mathematically the highest-risk zone for trend-continuation entries, as the market is actively deciding whether to bounce or reverse.
LONG / SHORT: The engine defaults to the macro trend direction ("LONG" in an uptrend, "SHORT" in a downtrend) as long as the price remains confidently outside the deep retracement zone (e.g., above the 0.382 in a bullish trend), signifying that the primary momentum remains intact. If the deep 0.786 level is broken against the trend, the script will mathematically flip the bias, assuming a structural reversal.
How to Use It
Traders should use this script to automate their top-down analysis. Rather than manually redrawing Fibonacci levels as new highs or lows are made, this indicator updates dynamically. During an established trend, traders should look for the AI Suggestion to switch to "Dangerous" (indicating price has entered the Golden Pocket) and await a definitive candlestick rejection pattern off the 0.500 or 0.618 level before re-entering the market in the direction of the macro trend.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。