PROTECTED SOURCE SCRIPT
Updated

MTF OB & FVG detector w/ Alerts - Public Version

990
# MTF OB & FVG検知器(アラート付き)

## 📊 概要
機関投資家のオーダーブロック(OB)検知とフェアバリューギャップ(FVG)分析を組み合わせた、包括的なマルチタイムフレームインジケーターです。複数の時間足にわたって高確率のサポート・レジスタンスゾーンを同時に識別し、統合された反発検知アラート機能を備えています。

## ✨ 主要機能

### 🎯 マルチタイムフレーム オーダーブロック(OB)
- **機関投資家のゾーン**: 大口機関が大量の注文を入れたエリアを検知
- **出来高分析**: 各オーダーブロック内の出来高分布(強気vs弱気)を表示
- **スマートスイング検知**: スイングハイ/ローに基づいてオーダーブロックを自動識別
- **ゾーン結合**: 異なる時間足の重複するオーダーブロックをインテリジェントに統合
- **自動無効化**: 価格がブレイクしたオーダーブロックを自動的に非表示
- **固定延長**: すべてのゾーンを右に50本分延長して表示の一貫性を確保
- **色オプション**:
- デフォルト(反転ON): 強気=赤、弱気=青
- 反転OFF: 強気=青、弱気=赤

### 📈 マルチタイムフレーム フェアバリューギャップ(FVG)
- **価格の非効率性検知**: 市場が急速に動きすぎた際の価格ギャップを識別
- **出来高分布**: 各ギャップ内の買い/売り出来高パーセンテージを表示
- **統計的フィルタリング**: 有意なギャップのみを表示(サイズ上位10%)
- **埋められた追跡**: 価格がギャップを埋めた際に自動的に非表示
- **固定延長**: すべてのギャップを右に50本分延長して表示の一貫性を確保
- **色オプション**:
- デフォルト(反転ON): 強気=オレンジ、弱気=水色
- 反転OFF: 強気=水色、弱気=オレンジ

### ⏱️ サポートする時間足
- **1分足** ✅(デフォルト有効)
- **5分足** ✅(デフォルト有効)
- **15分足** ✅(デフォルト有効)
- **60分足(1時間足)** ✅(デフォルト有効)
- **240分足(4時間足)** ⬜(デフォルト無効)

### 🔔 インテリジェント反発アラート
- **統合検知**: OBまたはFVGゾーンからの反発時にアラート発動
- **強気反発**: サポートゾーンから上方へ反発した際に通知
- **弱気反発**: レジスタンスゾーンから下方へ反発した際に通知
- **マルチタイムフレーム監視**: 有効化されたすべての時間足を同時に追跡
- **エッジ検知**: 新しい反発のみアラート(スパム防止)

## 📖 使用方法

### 初期セットアップ
1. インジケーターをTradingViewチャートに追加
2. どの時間足でも動作しますが、日中トレードには1分~15分足を推奨
3. 有効化されたすべての時間足のOBとFVGゾーンが表示されます

### 表示の理解

#### オーダーブロック(OB)
**視覚要素:**
- **ゾーンボックス**: オーダーブロックエリアを示す色付き長方形
- 赤色ボックス = 強気OB(サポート候補)
- 青色ボックス = 弱気OB(レジスタンス候補)
- **出来高バー**(左側): OB形成時の出来高分布を表示
- 緑部分 = 強気出来高
- 赤部分 = 弱気出来高
- **テキストラベル**(右側): 時間足と総出来高を表示
- 例: 「5m OB」と出来高量

**解釈:**
- 強気OB = 機関投資家が買い注文を持っている可能性が高いエリア
- 弱気OB = 機関投資家が売り注文を持っている可能性が高いエリア
- 高出来高 = より強力なゾーン
- 複数時間足の重なり = より重要なゾーン

#### フェアバリューギャップ(FVG)
**視覚要素:**
- **ギャップボックス**: 価格ギャップを示す色付き長方形
- オレンジ色ボックス = 強気FVG(サポート候補)
- 水色ボックス = 弱気FVG(レジスタンス候補)
- **出来高バー**(ギャップ内): 買い/売り出来高パーセンテージを表示
- **テキストラベル**: 時間足と出来高を表示

**解釈:**
- 強気FVG = 現在価格より下の価格ギャップで、サポートとして機能する可能性
- 弱気FVG = 現在価格より上の価格ギャップで、レジスタンスとして機能する可能性
- ギャップは価格が戻ってくる際に「埋められる」ことが多い
- 未埋めのギャップはサポート/レジスタンスとして機能する確率が高い

### トレード戦略

#### 1. コンフルエンストレード(最も高確率)
複数の要素が重なるエリアを探します:
- ✅ 複数時間足のOBが重なる
- ✅ FVGとOBが重なる
- ✅ 上位時間足のゾーンと下位時間足のエントリーポイントが一致

**例:**
```
15分足強気OB + 5分足強気FVG = 強力なサポートエリア
価格がこのゾーンに到達し、強気反転を示すのを待つ
```

#### 2. 反発トレード
- アラートで反発通知を監視
- プライスアクション(ローソク足パターン、出来高急増)で反発を確認
- 反発方向にエントリー、ゾーンの下/上にストップロス設置
- ターゲット: 次のOB/FVGゾーンまたは主要なレジスタンス/サポートレベル

#### 3. ブレイクアウトトレード
- ブレイクされるOB/FVGゾーンを監視
- 高出来高を伴う強いブレイクはトレンド継続を示唆
- ブレイクされたゾーンのリテストを待ってからエントリー
- ブレイク方向にトレード

#### 4. マルチタイムフレーム分析
- **上位時間足(60分、15分)**: 主要ゾーンと全体的なトレンドを識別
- **下位時間足(5分、1分)**: エントリーとエグジットポイントを微調整
- 常に下位時間足より上位時間足のゾーンを優先

### アラートの設定方法

1. 「その他」(⋯)→「アラートを追加」をクリック
2. 3つのアラート条件から1つ選択:
- **「OB/FVG Bounce (Any)」**: すべての反発でアラート(強気または弱気)
- **「Bullish Bounce (OB/FVG)」**: 強気反発のみ
- **「Bearish Bounce (OB/FVG)」**: 弱気反発のみ
3. 希望の通知方法を設定(ポップアップ、メール、ウェブフックなど)
4. 有効化された任意の時間足のゾーンから価格が反発した際にアラートが発動

### カスタマイズオプション

#### 一般設定
- **Show Historic Zones**: 無効化されたOBゾーンの表示/非表示を切り替え
- **Volumetric Info**: 出来高分布バーの表示/非表示
- **Zone Invalidation**: 無効化方法を「Wick」または「Close」から選択
- **Zone Count**: 過去のOBゾーン数を調整(High/Medium/Low/One)
- **Swing Length**: OB検知の感度(デフォルト: 3)

#### オーダーブロックの色
- **Invert Colors OB**: 強気/弱気の色を入れ替え
- ON: 強気=赤、弱気=青(デフォルト)
- OFF: 強気=青、弱気=赤

#### フェアバリューギャップ設定
- **Show Fair Value Gaps**: すべてのFVG表示のマスタートグル
- **FVG Mitigation Source**: ギャップ埋め検知に「close」または「high/low」を使用
- **Bullish/Bearish FVG**: 各ギャップタイプの個別トグル
- **FVG Volume Bars**: 出来高分布の表示/非表示
- **Invert FVG Colors**: 強気/弱気の色を入れ替え
- ON: 強気=オレンジ、弱気=水色(デフォルト)
- OFF: 強気=水色、弱気=オレンジ

#### マルチタイムフレーム選択
特定の時間足を有効化/無効化:
- ✅ 1分足(デフォルト ON)
- ✅ 5分足(デフォルト ON)
- ✅ 15分足(デフォルト ON)
- ✅ 60分足(デフォルト ON)
- ⬜ 240分足(デフォルト OFF)

#### アラート設定
- **Enable Alerts**: すべてのアラートのマスタートグル
- **Alert on Bullish Bounce**: 強気反発通知を受信
- **Alert on Bearish Bounce**: 弱気反発通知を受信

## ⚙️ 技術詳細

### パフォーマンス最適化
- **最大ボックス数**: 500(パフォーマンス最適化)
- **Max Bars Back**: 500(過去データとのバランス)
- **ゾーン延長**: 右に50本分固定
- **メモリ管理**: 古いゾーンの自動クリーンアップ

### 検知ロジック

**オーダーブロック形成:**
1. 指定されたスイング期間を使用してスイングハイ/ローを識別
2. 価格がスイングポイントをブレイク
3. スイング前の2-3本の足からOBゾーンを作成
4. 無効化を監視(価格がOBを突破)

**フェアバリューギャップ形成:**
1. 現在の足と2本前の足を比較
2. 高値/安値レベル間にギャップが存在するか確認
3. 統計的有意性でフィルタリング(上位10%)
4. ギャップエリアにFVGゾーンを作成
5. 消滅を監視(価格がギャップを埋める)

**反発検知:**
- OBの場合: 価格がゾーンに入る → 有利な方向にゾーン外で終値
- FVGの場合: 価格がゾーンに触れる → 有利な方向にゾーン外で終値
- エッジ検知: 新しい反発のみトリガー(繰り返しシグナルなし)

## 💡 Tips

1. **上位時間足から開始**: まず60分足と15分足のゾーンで全体的な市場構造を確認
2. **確認を待つ**: ゾーンで即座にエントリーせず、反発確認を待つ
3. **ストップロスを使用**: 常にゾーンの外にストップを配置(安全マージンとして5-10pips)
4. **出来高が重要**: 高出来高のゾーンは一般的により信頼性が高い
5. **時間経過**: 古いゾーン(左側)は一般的に新しいゾーンより信頼性が低い
6. **コンフルエンスが王様**: より多くの時間足/インジケーターが揃うほど、強力なセットアップ
7. **セッション認識**: 高出来高セッション(ロンドン、NY開始)で作成されたゾーンは通常より強い

## ⚠️ リスク免責事項

このインジケーターは教育および情報提供のみを目的として提供されています。金融商品の取引には重大な損失リスクが伴い、すべての投資家に適しているわけではありません。過去の実績は将来の結果を示すものではありません。常に:
- 独自の調査と分析を実施
- 適切なリスク管理を使用(ポジションサイジング、ストップロス)
- 失う余裕のある金額以上をリスクにさらさない
- 認可された金融アドバイザーへの相談を検討
- リアルマネーでトレードする前にデモ口座で練習

## 📝 クレジット

このインジケーターは以下のコンセプトを組み合わせ、強化したものです:
- **Volumized Order Blocks**: 出来高分析付き機関投資家オーダーブロック検知
Order Blocks | Flux Charts


- **Volumatic Fair Value Gaps**: 出来高分布付きフェアバリューギャップ検知
Volumatic Fair Value Gaps [BigBeluga]



## 📜 ライセンス

Mozilla Public License 2.0 (MPL-2.0)
mozilla.org/MPL/2.0/

---

**バージョン**: 1.0
**Pine Scriptバージョン**: 6
**最終更新**: 2024年11月

質問、提案、バグ報告については、下記にコメントしてください!


---

# MTF OB & FVG Detector with Alerts

## 📊 Overview
A comprehensive multi-timeframe indicator that combines institutional Order Blocks (OB) detection with Fair Value Gaps (FVG) analysis. This tool helps traders identify high-probability support and resistance zones across multiple timeframes simultaneously, with integrated bounce detection alerts.

## ✨ Key Features

### 🎯 Multi-Timeframe Order Blocks (OB)
- **Institutional Zones**: Detects areas where large institutions have placed significant orders
- **Volumetric Analysis**: Displays volume distribution (bullish vs bearish) within each order block
- **Smart Swing Detection**: Automatically identifies order blocks based on swing highs/lows
- **Zone Combination**: Intelligently merges overlapping order blocks from different timeframes
- **Automatic Invalidation**: Hides order blocks when price breaks through them
- **Fixed Extension**: All zones extend 50 bars to the right for consistent visualization
- **Color Options**:
- Default (Invert ON): Bullish = Red, Bearish = Blue
- Invert OFF: Bullish = Blue, Bearish = Red

### 📈 Multi-Timeframe Fair Value Gaps (FVG)
- **Price Inefficiency Detection**: Identifies gaps in price action where market moved too quickly
- **Volume Distribution**: Shows bull/bear volume percentage within each gap
- **Statistical Filtering**: Only displays significant gaps (top 10% by size)
- **Mitigation Tracking**: Automatically hides gaps when price fills them
- **Fixed Extension**: All gaps extend 50 bars to the right for consistent visualization
- **Color Options**:
- Default (Invert ON): Bullish = Orange, Bearish = Aqua
- Invert OFF: Bullish = Aqua, Bearish = Orange

### ⏱️ Supported Timeframes
- **1 Minute** ✅ (Enabled by default)
- **5 Minutes** ✅ (Enabled by default)
- **15 Minutes** ✅ (Enabled by default)
- **60 Minutes (1 Hour)** ✅ (Enabled by default)
- **240 Minutes (4 Hours)** ⬜ (Disabled by default)

### 🔔 Intelligent Bounce Alerts
- **Combined Detection**: Triggers when price bounces from either OB or FVG zones
- **Bullish Bounce**: Notifies when price bounces upward from support zones
- **Bearish Bounce**: Notifies when price bounces downward from resistance zones
- **Multi-Timeframe Monitoring**: Tracks all enabled timeframes simultaneously
- **Edge Detection**: Only alerts on new bounces to avoid spam

## 📖 How to Use

### Initial Setup
1. Add the indicator to your TradingView chart
2. Works on any timeframe, but 1-minute to 15-minute charts recommended for intraday trading
3. The indicator will display OB and FVG zones from all enabled timeframes

### Understanding the Display

#### Order Blocks (OB)
**Visual Elements:**
- **Zone Box**: Colored rectangle showing the order block area
- Red box = Bullish OB (potential support)
- Blue box = Bearish OB (potential resistance)
- **Volume Bars** (left side): Shows volume distribution during OB formation
- Green portion = Bullish volume
- Red portion = Bearish volume
- **Text Label** (right side): Displays timeframe and total volume
- Example: "5m OB" with volume amount

**Interpretation:**
- Bullish OB = Area where institutions likely have pending buy orders
- Bearish OB = Area where institutions likely have pending sell orders
- Higher volume = Stronger zone
- Multiple timeframe confluence = More significant zone

#### Fair Value Gaps (FVG)
**Visual Elements:**
- **Gap Box**: Colored rectangle showing the price gap
- Orange box = Bullish FVG (potential support)
- Aqua box = Bearish FVG (potential resistance)
- **Volume Bars** (within gap): Shows bull/bear volume percentage
- **Text Label**: Displays timeframe and volume

**Interpretation:**
- Bullish FVG = Price gap below current price that may act as support
- Bearish FVG = Price gap above current price that may act as resistance
- Gaps often get "filled" as price returns to these levels
- Unfilled gaps have higher probability of providing support/resistance

### Trading Strategies

#### 1. Confluence Trading (Highest Probability)
Look for areas where multiple elements align:
- ✅ OB from multiple timeframes overlap
- ✅ FVG overlaps with OB
- ✅ Higher timeframe zone aligns with lower timeframe entry

**Example:**
```
15min Bullish OB + 5min Bullish FVG = Strong support area
Wait for price to reach this zone and show bullish reversal
```

#### 2. Bounce Trading
- Monitor alerts for bounce notifications
- Confirm bounce with price action (candlestick patterns, volume spike)
- Enter in direction of bounce with stop loss below/above the zone
- Target: Next OB/FVG zone or key resistance/support level

#### 3. Breakout Trading
- Watch for OB/FVG zones that get broken
- A strong break with high volume indicates trend continuation
- Wait for retest of broken zone before entering
- Trade in direction of the break

#### 4. Multi-Timeframe Analysis
- **Higher timeframes (60min, 15min)**: Identify major zones and overall trend
- **Lower timeframes (5min, 1min)**: Fine-tune entry and exit points
- Always respect higher timeframe zones over lower timeframe zones

### Setting Up Alerts

1. Click on "More" (⋯) → "Add alert"
2. Choose one of three alert conditions:
- **"OB/FVG Bounce (Any)"**: Alerts on any bounce (bullish or bearish)
- **"Bullish Bounce (OB/FVG)"**: Only bullish bounces
- **"Bearish Bounce (OB/FVG)"**: Only bearish bounces
3. Set your preferred notification method (popup, email, webhook, etc.)
4. The alert will trigger when price bounces from any enabled timeframe's zone

### Customization Options

#### General Settings
- **Show Historic Zones**: Toggle display of invalidated OB zones
- **Volumetric Info**: Show/hide volume distribution bars
- **Zone Invalidation**: Choose "Wick" or "Close" for invalidation method
- **Zone Count**: Adjust number of historical OB zones (High/Medium/Low/One)
- **Swing Length**: Sensitivity for OB detection (default: 3)

#### Order Block Colors
- **Invert Colors OB**: Swap bullish/bearish colors
- ON: Bullish=Red, Bearish=Blue (default)
- OFF: Bullish=Blue, Bearish=Red

#### Fair Value Gap Settings
- **Show Fair Value Gaps**: Master toggle for all FVG display
- **FVG Mitigation Source**: "close" or "high/low" for gap filling detection
- **Bullish/Bearish FVG**: Individual toggles for each gap type
- **FVG Volume Bars**: Show/hide volume distribution
- **Invert FVG Colors**: Swap bullish/bearish colors
- ON: Bullish=Orange, Bearish=Aqua (default)
- OFF: Bullish=Aqua, Bearish=Orange

#### Multi-Timeframe Selection
Enable/disable specific timeframes:
- ✅ 1 Min (default ON)
- ✅ 5 Min (default ON)
- ✅ 15 Min (default ON)
- ✅ 60 Min (default ON)
- ⬜ 240 Min (default OFF)

#### Alert Settings
- **Enable Alerts**: Master toggle for all alerts
- **Alert on Bullish Bounce**: Receive bullish bounce notifications
- **Alert on Bearish Bounce**: Receive bearish bounce notifications

## ⚙️ Technical Details

### Performance Optimization
- **Max Boxes**: 500 (optimized for performance)
- **Max Bars Back**: 500 (balanced historical data)
- **Zone Extension**: Fixed 50 bars to the right
- **Memory Management**: Automatic cleanup of old zones

### Detection Logic

**Order Block Formation:**
1. Identify swing high/low using specified swing length
2. Price breaks the swing point
3. Create OB zone from the 2-3 bars before the swing
4. Monitor for invalidation (price breaking through OB)

**Fair Value Gap Formation:**
1. Compare current bar with 2 bars ago
2. Check if gap exists between high/low levels
3. Filter by statistical significance (top 10%)
4. Create FVG zone in the gap area
5. Monitor for mitigation (price filling the gap)

**Bounce Detection:**
- For OB: Price enters zone → Closes outside zone in favorable direction
- For FVG: Price touches zone → Closes outside zone in favorable direction
- Edge detection: Only triggers on new bounces (not repeated signals)

## 💡 Tips

1. **Start with Higher Timeframes**: Check 60min and 15min zones first for overall market structure
2. **Wait for Confirmation**: Don't enter immediately at a zone; wait for bounce confirmation
3. **Use Stop Losses**: Always place stops beyond the zone (5-10 pips for safety margin)
4. **Volume Matters**: Zones with higher volume are generally more reliable
5. **Time Decay**: Older zones (further left) are generally less reliable than recent zones
6. **Confluence is King**: The more timeframes/indicators align, the stronger the setup
7. **Session Awareness**: Zones created during high-volume sessions (London, NY open) are typically stronger

## ⚠️ Risk Disclaimer

This indicator is provided for educational and informational purposes only. Trading financial instruments involves substantial risk of loss and is not suitable for every investor. Past performance is not indicative of future results. Always:
- Conduct your own research and analysis
- Use proper risk management (position sizing, stop losses)
- Never risk more than you can afford to lose
- Consider consulting with a licensed financial advisor
- Practice on a demo account before trading with real money

## 📝 Credits

This indicator combines and enhances concepts from:
- **Volumized Order Blocks**: Institutional order block detection with volume analysis
Order Blocks | Flux Charts


- **Volumatic Fair Value Gaps**: Fair value gap detection with volume distribution
Volumatic Fair Value Gaps [BigBeluga]



## 📜 License

Mozilla Public License 2.0 (MPL-2.0)
mozilla.org/MPL/2.0/

---

**Version**: 1.0
**Pine Script Version**: 6
**Last Updated**: November 2024

For questions, suggestions, or bug reports, please comment below!


Release Notes
Changed OB text color (White -> Black)
Release Notes
Optimized memory usage so we can use REPLAY feature.
Release Notes
Tweaked memory setting and disabled 60min OB/FVG by default so we can execute "REPLAY".
Release Notes
fixed BUG, OB does not disappear even after break.
Release Notes
disabled volume bars by default to improve visibility.
Release Notes
improved visibility.
Release Notes
Fixed bug, unable to remove some OB after its break.
Release Notes
improved visibility.
fixed memory issue.
Removed MTF FVG feature so we can save memory consumption.
Release Notes
fixed bug , unable to remove bearish OB.
Release Notes
fixed minor bug, unable to show FVG due to limit of maximum boxes numbers.
Enabled the feature "invert OB/FVG colors" by default.
Please disable the feature if you are using default chart in trading view.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.