PROTECTED SOURCE SCRIPT

MirPapa:ICT:HTF: FVG Threeple

144
# MirPapa:ICT:FVG Double HTF

**Version:** Pine Script® v6
**Author:** © goodia
**License:** MPL-2.0 (Mozilla Public License 2.0)

---

## Overview
“MirPapa:ICT:FVG Double HTF” is a TradingView indicator that identifies and visualizes Fair Value Gaps (FVG) on two higher time frames (HighTF and MidTF) simultaneously. It can also draw FVG boxes on the current chart’s time frame. When “Overlap Mode” is enabled, the indicator displays only the intersection of HighTF and MidTF FVG areas.

---

## Key Features

- **HighTF FVG**
- Detects bullish and bearish FVGs on a user-selected upper time frame (e.g., 4H).
- Draws colored boxes around gap ranges, optionally with a midpoint line.
- Automatically extends boxes on every bar and finalizes (recolors) them after a specified number of closes beyond the gap.

- **MidTF FVG**
- Same as HighTF FVG but for a second, intermediate time frame (e.g., 1H).
- Runs in parallel to HighTF logic, with separate color and transparency settings.

- **CurrentTF FVG (Optional)**
- If enabled, draws FVG boxes using the chart’s own time frame.
- Behaves identically: extends until broken by price, then finalizes.

- **Overlap Mode**
- When enabled, hides all individual HighTF and MidTF boxes.
- Instead, computes and displays only their overlapping rectangle(s)—separate for bullish and bearish gaps.

---

## Inputs & Configuration

- **Common Inputs**
- **Enable High/Mid Overlap Mode** (`boolean`): Show only overlapping HighTF + MidTF FVG areas.
- **Box Close Color** (`color`): Color applied to any FVG box when it is finalized.

- **HighTF FVG Settings**
- **HighTF Label** (`dropdown`): Choose a Korean label (e.g., “4시간”) that maps to a Pine timeframe (e.g., “240”).
- **Enable HighTF FVG Boxes** (`boolean`): Toggle drawing of HighTF FVG boxes.
- **Enable HighTF FVG Midlines** (`boolean`): Toggle midpoint line inside each HighTF box.
- **HighTF FVG Close Count** (`integer` 1–10): Number of closes beyond the gap before finalizing the box.
- **HighTF FVG Bull Color** (`color`): Fill & border color for bullish HighTF gaps.
- **HighTF FVG Bear Color** (`color`): Fill & border color for bearish HighTF gaps.
- **HighTF Box Transparency** (`integer` 1–100): Opacity level for HighTF box fills.

- **MidTF FVG Settings**
- **MidTF Label** (`dropdown`): Choose a Korean label (e.g., “1시간”) mapped to a Pine timeframe.
- **Enable MidTF FVG Boxes** (`boolean`): Toggle drawing of MidTF FVG boxes.
- **Enable MidTF FVG Midlines** (`boolean`): Toggle midpoint line inside each MidTF box.
- **MidTF FVG Close Count** (`integer` 1–10): Number of closes beyond the gap before finalizing the box.
- **MidTF FVG Bull Color** (`color`): Fill & border color for bullish MidTF gaps.
- **MidTF FVG Bear Color** (`color`): Fill & border color for bearish MidTF gaps.
- **MidTF Box Transparency** (`integer` 1–100): Opacity level for MidTF box fills.

- **CurrentTF FVG Settings**
- **Enable CurrentTF FVG Boxes** (`boolean`): Draw FVG boxes on the chart’s own timeframe.
- **Enable CurrentTF FVG Midlines** (`boolean`): Toggle midpoint line inside each CurrentTF box.
- **CurrentTF FVG Close Count** (`integer` 1–10): Number of closes beyond the gap before finalizing the box.
- **CurrentTF FVG Bull Color** (`color`): Fill & border color for bullish CurrentTF gaps.
- **CurrentTF FVG Bear Color** (`color`): Fill & border color for bearish CurrentTF gaps.
- **CurrentTF Box Transparency** (`integer` 1–100): Opacity level for CurrentTF box fills.

---

## How It Works

1. **Time Frame Conversion**
Korean labels (e.g., “4시간”, “1시간”) are converted internally to Pine timeframe strings via `GetHtfFromLabel()`.

2. **Data Retrieval**
For each chosen TF (HighTF, MidTF, and optionally CurrentTF), the script fetches OHLC and historical values using `GetHTFrevised()`.
- Tracks `bar_index` from that TF to align box drawing on the chart’s base timeframe.

3. **Box Lifecycle**
- **Creation**: On each new TF bar, if a bullish gap (`low[1] > high[3]`) or bearish gap (`low[3] > high[1]`) is detected, `CreateBoxData()` registers a new `BoxData` struct and draws an initial box.
- **Extension**: On every chart bar, `ProcessBoxDatas()` extends each active box’s right edge and updates internal “touch stage” and volume.
- **Finalization**: After the specified number of closes beyond the gap, `setBoxFinalize()` disables the box and changes its border & fill to the “Box Close Color”.

4. **Overlap Mode**
- When enabled, HighTF and MidTF boxes are not drawn individually.
- Instead, at each bar, the script iterates over all active HighTF boxes and all active MidTF boxes, computes their intersection rectangle (if any), and draws only that overlapping area (distinct handling for bullish vs. bearish gaps).

---

## Installation & Usage

1. **Copy & Paste**
Copy the entire Pine Script code into TradingView’s Pine Editor.
Click “Add to Chart.”

2. **Configure Inputs**
- Choose your HighTF and MidTF via the dropdown menus.
- Enable or disable FVG boxes/midlines for each TF.
- Adjust colors, transparency, and “Close Count” settings to taste.
- Toggle “Overlap Mode” if you only want to see common areas between HighTF and MidTF gaps.

3. **Interpretation**
- **Active Boxes** extend to the right as new bars form. When price closes beyond a gap (per “Close Count”), the box is finalized and recolored to the close color.
- In **Overlap Mode**, you’ll see only the overlapping region between HighTF and MidTF gaps, updated on every bar.

Enjoy precise FVG visualization across multiple time frames!

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.