Purpose of the Code:
This Pine Script™ code defines an indicator called "Auto Fibonacci Mode" that automatically plots Fibonacci retracement and extension levels based on recent price data, providing traders with reference levels for potential support and resistance. It also offers an "Auto" mode that determines levels based on the selected moving average type (e.g., EMA, SMA) for added flexibility in trend identification.
Key Components and Functionalities:
Inputs:
lookback (Lookback): Determines how many bars back to look when identifying the highest and lowest prices.
reverse: Reverses the direction of Fibonacci calculations, which is helpful for analyzing both uptrends and downtrends.
auto: When enabled, this option automatically adjusts Fibonacci levels based on a moving average.
mod: Allows the user to select a specific moving average type (EMA, SMA, RMA, HMA, or WMA) for use in "Auto" mode.
Label and Color Options: Customize the display of Fibonacci labels, colors, and whether to show the highest and lowest levels on the chart.
Fibonacci Levels:
Sixteen Fibonacci levels are configurable in the input options, allowing users to choose traditional retracement levels (e.g., 0.236, 0.5, 1.618) as well as custom levels.
These levels are calculated dynamically and adjusted based on the highest and lowest price range within the lookback period.
Calculation of Direction and Fibonacci Levels:
Moving Average Direction: Using the specified moving average, the code evaluates the price direction to determine the trend (upward or downward). This direction can be reversed if the user selects the reverse option.
Fibonacci Level Calculation: Each level is computed based on the highest and lowest prices over the lookback range and adjusted according to the selected trend direction and moving average type.
Plotting Fibonacci Levels:
The script generates lines on the chart to represent each Fibonacci level, with customizable gradient colors.
Labels displaying level values and prices can be enabled, providing easy identification of each level on the chart.
Additional Lines:
Lines representing the highest and lowest prices within the lookback range can also be displayed, highlighting recent support and resistance levels for added context.
Usage:
The Auto Fibonacci Mode indicator is designed for traders interested in Fibonacci retracement and extension levels, particularly those seeking automatic trend detection based on moving averages.
This indicator enables:
Automatic adjustment of Fibonacci levels based on selected moving average type.
Quick visualization of support and resistance areas without manual adjustments.
Analysis flexibility with customizable levels and color gradients for easier trend and reversal identification.
This tool is valuable for traders who rely on Fibonacci analysis and moving averages as part of their technical analysis strategy.
Important Note:
This script is provided for educational purposes and does not constitute financial advice. Traders and investors should conduct their research and analysis before making any trading decisions.