OPEN-SOURCE SCRIPT

FVG MTF + 50%

285
Pine Script®
// This indicator identifies Fair Value Gaps (FVGs) on M15, H1, and H4 timeframes, highlights them on the chart as colored boxes, draws the 50% median line, // and displays price labels for the 0%, 50%, and 100% levels of each gap. // It also tracks when gaps are “filled” (mitigated) and logs counts on a dashboard, providing real-time metrics on open/filled FVGs for liquidity analysis. // // Key Features: // 1. Multi‐Timeframe Detection: Scans M15, H1, H4 for three‐bar FVG patterns using a configurable threshold. // 2. Colored Zones and Median Lines: Draws bullish (green) and bearish (red) gap boxes, bordered in white, with a dashed white line at the midpoint. // 3. Price Labels: Optionally annotates each gap with “0% FVG = $X,” “50% FVG = $Y,” and “100% FVG = $Z” at the moment of detection. // 4. Gap Mitigation: Monitors price re‐entry into a gap; when filled, it removes the box and logs a dashed line at the fill price. // 5. Dashboard: Counts total bullish/bearish FVGs and calculates the percentage filled on each timeframe. // 6. Alerts: Configurable alerts for new gap creation and fill events at 0%, 50%, and 100% levels. // // Implementation Details: // • Detection Logic: A three-bar gap occurs when the middle bar’s low is above the prior bar’s high (bullish) or its high is below the prior bar’s low (bearish). // A “threshold” parameter filters minor gaps based on relative size. // • Data Structures: Uses Pine v6’s user‐defined “fvg” type to store gap high, low, direction, and timestamp. Arrays track open boxes, lines, labels for each timeframe. // • Drawing: // – box.new() draws transparent rectangles spanning 500 bars into the future. // – line.new() draws dashed median lines and mitigation lines when gaps are filled. // – label.new() places price annotations at the current right edge with textalign=text.align_right. // • Dashboard: table.new() creates a 3×3 panel showing “Bullish”/“Bearish” counts and “Mitigated” percentages in real time. // • Alerts: alertcondition() triggers when new gaps form or are mitigated at specified percentages. // // Usage: // • Add to chart: Apply the script; enable or disable timeframes via checkboxes (Enable FVG M15, H1, H4). // • Configure text labels: Toggle “Text” to show or hide on‐chart price annotations. // • Monitor dashboard: Observe counts and fill rates to gauge market liquidity pressure. // • Set alerts: Enable alerts for specific levels (0%, 50%, 100%) and timeframes as needed. // // Potential Extensions: // • Customizable lookback on fill monitoring (beyond “showLast” parameter). // • Dynamic threshold based on ATR or volatility metrics instead of static percentage. // • Integration with order‐flow or volume data to refine gap significance. // • Expanded timeframes (D1, W, etc.) for higher‐timeframe liquidity profiling. // // ============================================================================= // // © 2025. Licensed under CC BY‐NC‐SA 4.0 International. // Feel free to reference academic works (Hasbrouck, Bouchaud, O’Hara) for theoretical context. // // End of Description.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.