PROTECTED SOURCE SCRIPT
已更新

[longshorti] Auto Fibonacci Grid (Long/Short)

66
🌟 [longhorti] Auto Fibonacci Grid (Long/Short) — Smart Retracement Tool

The [longshorti] Auto Fibonacci Grid (Long/Short) is an advanced trading utility designed to automate the process of identifying key Fibonacci retracement levels for both bullish and bearish swings. This indicator provides traders with precise zones for potential entries during market corrections.

✨ Key Features and Originality:

True Auto-Detection: The script automatically analyzes the market impulse within the lookback window to determine if the current grid should be calculated for a Bullish (Long) or Bearish (Short) scenario.

Impulse Filtered Alerts: A custom alert system triggers only when the price enters your designated key zone and when the underlying market impulse exceeds a user-defined Minimum Impulse Percentage. This is crucial for filtering out false signals generated by weak, consolidating movements.

Dynamic Correction Zones: Define any range of Fibonacci levels (e.g., 0.5 to 0.618) to be highlighted as your Key Zone (Buy or Sell Zone), with dedicated color schemes for Long and Short setups.

Visual Tracking: Fills between levels dynamically change color to indicate the impulse direction and track which zones have already been successfully tested by the price action.

🧠 How It Works:

The indicator scans the last N bars (Fixed Window Lookback) to identify the Low and High of the swing. It then compares the bar indices to determine the final direction. The calculateFibPrice function internally adapts to project correction levels from the High down (for Long) or from the Low up (for Short), ensuring the grid is always applied correctly to the impulse.

⚙️ Settings Overview:

The script includes comprehensive settings for:

Grid Mode: Auto Detect, Force Bullish, or Force Bearish.

Impulse Filter: Set the minimum percentage (0% = Off) required for alerts to trigger.

MFI/RSI Settings: Used for additional signal confirmation (internal logic).

Display & Style: Full control over line colors, fill colors, and text sizes.
版本注释
This indicator draws a dynamic Fibonacci Retracement Grid within a fixed lookback window, automatically adjusting the grid's direction (Long/Short) based on the price impulse. It also incorporates an MFI/RSI momentum filter and highlights a customizable Correction/Key Zone with dedicated alerts.

1. Core Logic & Impulse Detection

快照

Fixed Window Analysis: The indicator analyzes a fixed number of recent bars (fibLen, default 200 bars) to find the absolute High and Low within that window.

Direction Determination (isBullishImpulse):

If Grid Mode is set to "Auto Detect", the script determines the current price impulse direction:

Bullish (Long): If the bar index of the High is greater than or equal to the bar index of the Low (meaning the High was reached after the Low).

Bearish (Short): If the bar index of the High is less than the bar index of the Low.

The direction can be overridden using "Force Bullish (Long)" or "Force Bearish (Short)".

Fibonacci Calculation: The calculateFibPrice function adjusts the calculation based on the direction:

Long: Retracements are calculated down from the High (e.g., 0.0 is Low, 1.0 is High).

Short: Retracements are calculated up from the Low (e.g., 0.0 is High, 1.0 is Low).

2. MFI/RSI Momentum Filter

The script calculates a smoothed RSI based on the Money Flow Index (MFI) (FIBOmfirsi).

This calculated momentum is used to identify Overbought (isOverbought) and Oversold (isOversold) conditions, which are typically used for trade signal confirmation (though the signals aren't explicitly drawn on the chart in the provided code, the variables are calculated).

3. Dynamic Grid & Display

快照

Lines and Fills: The grid lines (levels 0.236, 0.382, 0.500, etc.) are dynamically drawn and updated on every bar.

Extreme Colors: The 0.0 and 1.0 lines use specific, thicker colors (line0Color and line1Color) based on whether the impulse is Bullish or Bearish.

Recoloring Logic: Fills between the Fibonacci levels change color from fillColorBase to an Active Color (impulseActiveColor) once the price has passed that zone, signaling a potential completion of a previous correction.

🚨 Correction Zone and Alert System
The most advanced feature is the definition of a specific correction zone with a custom alert.

1. Defining the Key Zone

The user defines a Zone Start (zoneLevelA) and Zone End (zoneLevelB) using standard Fibonacci levels (e.g., 0.500 and 0.618).

The script calculates the actual price range (zoneTop and zoneBottom) for this zone based on the current impulse.

The box corresponding to this zone is highlighted with a specific active color (activeZoneColor or activeZoneColorBear).

2. Alert Logic

The alert logic is triggered only when all of the following conditions are met:

Alerts are enabled (enableAlert = true).

The alert has not been triggered yet on the current impulse (not alert050618Triggered).

The Impulse Magnitude Check passes (the absolute price change of the impulse must be greater than or equal to minImpulsePercent).

Price Entry: The current bar's price (Low for Long, High for Short) has entered the calculated A-B Correction Zone (hasEnteredZone).

If all conditions are met, a one-time alert is fired using the specified message (alertMessageBull or alertMessageBear).

版本注释
The Alerts settings has been updated.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。