OPEN-SOURCE SCRIPT
ที่อัปเดต: MIG and MC

发布简介(中文)
MIG and MC 指标帮助日内交易者快速识别微型缺口(Micro Gap)与微型通道(Micro Channel)。脚本支持过滤开盘跳空、合并连续缺口,并自动绘制
FPL(Fair Price Line)延伸线,既可追踪缺口是否被填补,也能直观标注潜在的趋势结构。为了确保跨周期一致性,最新版本对开盘前后和跨日场景做了专门处理
主要特性
- 自动检测并显示看涨/看跌微型缺口,支持按需合并连续缺口。
- 自定义是否忽略开盘缺口、缺口显示范围与 FPL 样式。
- FPL 触及后即停止延伸,辅助研判缺口是否真正回补。
- 内置强收盘与缺口过滤的微型通道识别,可选多种严格程度。
- 适用于 1/5/9 分钟等日内周期,也适用于更长周期。
Recommended English Description
The MIG and MC indicator highlights Micro Gaps and Micro Channels so you can track true intraday imbalances without noise. It merges
consecutive gaps, projects Fair Price Lines (FPL) that stop once touched, and offers a full intraday-ready opening-gap filter so your
early bars stay clean. The latest update refines cross-session handling, giving reliable gap plots on 1-, 5-, and 9-minute charts as well as higher time frames.
Key Features
- Detects bullish and bearish micro gaps with optional gap merging.
- Toggle opening-gap filters and configure look back, visibility, and FPL style.
- FPL lines stop as soon as price revisits the gap, making gap closure obvious.
- Micro Channel mode uses strong-close and gap filters to mark high-quality trend legs.
- Consistent behavior across intraday and higher time frames.
MIG and MC 指标帮助日内交易者快速识别微型缺口(Micro Gap)与微型通道(Micro Channel)。脚本支持过滤开盘跳空、合并连续缺口,并自动绘制
FPL(Fair Price Line)延伸线,既可追踪缺口是否被填补,也能直观标注潜在的趋势结构。为了确保跨周期一致性,最新版本对开盘前后和跨日场景做了专门处理
主要特性
- 自动检测并显示看涨/看跌微型缺口,支持按需合并连续缺口。
- 自定义是否忽略开盘缺口、缺口显示范围与 FPL 样式。
- FPL 触及后即停止延伸,辅助研判缺口是否真正回补。
- 内置强收盘与缺口过滤的微型通道识别,可选多种严格程度。
- 适用于 1/5/9 分钟等日内周期,也适用于更长周期。
Recommended English Description
The MIG and MC indicator highlights Micro Gaps and Micro Channels so you can track true intraday imbalances without noise. It merges
consecutive gaps, projects Fair Price Lines (FPL) that stop once touched, and offers a full intraday-ready opening-gap filter so your
early bars stay clean. The latest update refines cross-session handling, giving reliable gap plots on 1-, 5-, and 9-minute charts as well as higher time frames.
Key Features
- Detects bullish and bearish micro gaps with optional gap merging.
- Toggle opening-gap filters and configure look back, visibility, and FPL style.
- FPL lines stop as soon as price revisits the gap, making gap closure obvious.
- Micro Channel mode uses strong-close and gap filters to mark high-quality trend legs.
- Consistent behavior across intraday and higher time frames.
เอกสารเผยแพร่
名称: MIG and MC — 微缺口与微通道识别概述:
自动识别价格中的微缺口(Micro Gaps, MIG)与微通道(Micro Channels, MC)。
提供“连续同向微缺口合并(CC MIG)”、强收盘过滤、忽略日内开盘跳空、以及灵活显示与样式控制。
缺口参考线(FPL)会在首次被触及时停止延伸,便于观察“触及/回补”行为。
判定逻辑:
微缺口(MIG)
看涨 MIG: high[2] <= low[0](启用“零高度 MIG”时为 <=,否则为 <)。
看跌 MIG: low[2] >= high[0](启用“零高度 MIG”时为 >=,否则为 >)。
绘制内容:以缺口边界价构建盒形区间与一条 FPL 参考线(看涨用绿色、看跌用红色)。
连续 MIG(CC MIG)启用时:同向连续缺口将被合并,绘制“主 FPL”与可选“次 FPL”(次 FPL 为起始价与当前极值的均值),两者在首次被触及时“钉住”并停止延伸。
微通道(MC)
看涨通道:一段连续“低点不破低”的序列,长度 ≥ 最小长度。
看跌通道:一段连续“高点不破高”的序列,长度 ≥ 最小长度。
严格过滤(可选):要求通道内至少出现一次强收盘(IBS > 69 为强阳,IBS < 31 为强阴)且包含至少一个同向 MIG。
可视化:通道进行中绘制动态趋势线;通道结束后固定最终线段。
主要参数(Inputs)
Micro Gap
Enable Micro Gap Detection: 是否启用 MIG 识别
Lookback Period: 回看范围(默认 200),超出范围的缺口自动清理
Enable Gap Closing: 开启“自动关闭”逻辑(缺口持续状态满足关闭条件时自动移除)
Show ZH MIG: 显示“零高度”缺口(包含等号的判定)
Show CC MIG: 合并连续同向 MIG,并绘制主/次 FPL
Ignore Opening Gaps: 日内忽略开盘跳空
Display
颜色与线型:看涨/看跌缺口颜色、FPL 颜色、线型(实线/虚线/点线)、线宽
Micro Channel
Enable Micro Channel Detection: 启用 MC 识别
Minimum Length: 最小通道长度(默认 3)
Trend Line Width / Opacity: 趋势线宽度与不透明度
Bullish/Bearish Channel Color: 多/空通道颜色
Require Strong Close & Micro Gap: 严格过滤(强收盘+内含 MIG)
使用建议:
任何周期均可用;日内建议开启“Ignore Opening Gaps”以排除日间开盘跳空干扰。
“Lookback Period”平衡画图数量与性能;默认 200 较为稳妥。
CC MIG 适合评估同向推进与层层推进的回补路径;FPL 被触后不再延伸,有助于直观看到“触及/回补”。
说明:
本指标不提供交易建议,仅供学习与研究。
未包含报警条件;如需提醒,可根据 FPL 触及或通道结束逻辑自行添加 alert 条件。
——
English Description
Name: MIG and MC — Micro Gaps & Micro Channels
Overview:
Detects Micro Gaps (MIG) and Micro Channels (MC) on any timeframe.
Supports merging consecutive same-direction gaps (CC MIG), strict filters for channels, ignoring intraday opening gaps, and rich display controls.
Fair Price Line (FPL) stops extending after first touch, helping visualize “touch/fill” behavior.
Logic:
Micro Gaps (MIG)
Bullish MIG: high[2] <= low[0] (inclusive when “Show ZH MIG” is on; otherwise strict <).
Bearish MIG: low[2] >= high[0] (inclusive when “Show ZH MIG” is on; otherwise strict >).
Visualization: a gap box plus one FPL at the gap boundary (green for bullish, red for bearish).
With CC MIG enabled: merges consecutive same-direction MIGs and draws a primary FPL and an optional secondary FPL (secondary = average of start price and current extreme). Both lines get “pinned” (stop extending) on first touch.
Micro Channels (MC)
Bullish channel: a run of non-decreasing lows, length ≥ minimum.
Bearish channel: a run of non-increasing highs, length ≥ minimum.
Strict filter (optional): requires at least one strong close inside the channel (IBS > 69 for bull, IBS < 31 for bear) and at least one same-direction MIG.
Visualization: dynamic line while active; final segment is fixed once the channel ends.
Key Inputs
Micro Gap
Enable Micro Gap Detection
Lookback Period (default 200): auto-cleans older items
Enable Gap Closing: auto-remove gaps that meet the closing condition
Show ZH MIG: allow zero-height gaps (inclusive inequalities)
Show CC MIG: merge consecutive same-direction MIGs with primary/secondary FPLs
Ignore Opening Gaps: ignore intraday session opens
Display
Colors and styles for gaps and FPLs: line style (solid/dashed/dotted) and width
Micro Channel
Enable Micro Channel Detection
Minimum Length (default 3)
Trend line width and opacity
Bullish/Bearish channel colors
Require Strong Close & Micro Gap (strict filter)
เอกสารเผยแพร่
# MIG and MC - Version 8.0 Release Notes## 📊 Intelligent FPL Drawing with Z-Score Analysis
---
## 🇺🇸 English Version
### 🎯 What's New
**Smart Dual-FPL System**
This major update introduces a statistical approach to FPL (Fill Price Level) drawing. Instead of simply counting consecutive gaps, the indicator now uses **Z-Score analysis** to intelligently determine when a gap is statistically significant enough to warrant drawing two FPLs (boundary + midpoint).
### ✨ Key Features
#### 1. **Z-Score Based Gap Analysis**
- Gaps are now measured against historical data using statistical Z-Score
- Large gaps (Z-Score > threshold) automatically draw 2 FPLs for better precision
- Small gaps draw only 1 FPL to avoid chart clutter
- **Unified logic**: Same intelligent decision-making for both single and consecutive MIGs
#### 2. **New Settings**
**Z-Score for FPL** section in indicator settings:
- `Gap Z-Score Lookback` (default: 20)
Number of historical gaps used to calculate average and standard deviation
- `Gap Z-Score Threshold` (default: 1.05)
Gaps with Z-Score above this threshold will draw 2 FPLs
**Recommended Settings:**
- **Conservative**: Threshold = 1.5 (fewer dual-FPLs, only very large gaps)
- **Balanced**: Threshold = 1.05 (default)
- **Aggressive**: Threshold = 0.5 or 0.8 (more dual-FPLs)
#### 3. **Debug Dashboard** 📈
Six new data window indicators help you understand the decision-making:
| Indicator | Description |
|-----------|-------------|
| **History Size** | Number of gaps in historical database (builds up to 20) |
| **Gap Avg** | Average gap size over lookback period |
| **Gap StdDev** | Standard deviation of historical gaps |
| **Last Gap Size** | Size of most recent gap (in price points) |
| **Last Gap Z-Score** | Z-Score of most recent gap ⭐ |
| **Threshold** | Current threshold setting (1.05) |
**How to use:** Open the Data Window (right panel) and hover over a gap bar to see these values.
### 🔧 Technical Improvements
#### Gap Size Calculation
- **Fixed**: Bullish gaps now correctly calculate as `currentLow - previousHigh`
- **Fixed**: Bearish gaps now correctly calculate as `previousLow - currentHigh`
- All gap sizes are now positive values
#### Consecutive MIG Logic
- **Fixed**: Continuous gaps now measure total sequence size, not individual bar gaps
- **Enhanced**: Z-Score updates dynamically as sequences extend
- **Optimized**: Historical data only updated at sequence start to prevent pollution
### 🎨 Usage Tips
1. **For volatile markets**: Lower the threshold to 0.5-0.8 to see more dual-FPLs
2. **For ranging markets**: Keep default 1.05 or increase to 1.5
3. **Testing**: Disable "Show CC MIG" to see debug data for individual gaps
4. **Best practice**: Wait for bar confirmation before analyzing debug values
### 📈 Why Z-Score?
Traditional methods treated all gaps equally. The Z-Score approach:
- ✅ Adapts to market volatility automatically
- ✅ Identifies truly anomalous gaps statistically
- ✅ Reduces noise in low-volatility periods
- ✅ Provides objective, data-driven FPL decisions
### 🐛 Bug Fixes
- Fixed negative gap size calculations for bullish MIGs
- Fixed Z-Score calculation for consecutive gap sequences
- Fixed historical array updating timing issues
- Improved debug variable updates for real-time visibility
---
## 🇨🇳 中文版本
### 🎯 更新内容
**智能双FPL系统**
此次重大更新引入了统计学方法来绘制FPL(填充价格水平线)。指标不再简单地计算连续缺口数量,而是使用**Z-Score分析**来智能判断缺口是否具有统计显著性,从而决定是否绘制两条FPL(边界+中点)。
### ✨ 核心功能
#### 1. **基于Z-Score的缺口分析**
- 使用历史数据的Z-Score统计方法衡量缺口大小
- 大缺口(Z-Score > 阈值)自动绘制2条FPL,提供更精细的价格参考
- 小缺口只绘制1条FPL,避免图表混乱
- **统一逻辑**:单个MIG和连续MIG使用相同的智能判断标准
#### 2. **新增设置参数**
在指标设置中新增**Z-Score for FPL**部分:
- `Gap Z-Score Lookback`(默认:20)
用于计算均值和标准差的历史缺口数量
- `Gap Z-Score Threshold`(默认:1.05)
Z-Score超过此阈值的缺口将绘制2条FPL
**推荐设置:**
- **保守型**:阈值 = 1.5(只对非常大的缺口绘制双FPL)
- **平衡型**:阈值 = 1.05(默认值)
- **激进型**:阈值 = 0.5 或 0.8(更多双FPL)
#### 3. **调试仪表板** 📈
6个新增数据窗口指标帮助您理解决策逻辑:
| 指标名称 | 说明 |
|---------|------|
| **History Size** | 历史数据库中的缺口数量(逐渐增长至20) |
| **Gap Avg** | 回看期内的平均缺口大小 |
| **Gap StdDev** | 历史缺口的标准差 |
| **Last Gap Size** | 最近缺口的大小(价格点数) |
| **Last Gap Z-Score** | 最近缺口的Z-Score值 ⭐ |
| **Threshold** | 当前阈值设置(1.05) |
**使用方法:** 打开数据窗口(右侧面板),将鼠标悬停在有缺口的K线上查看这些数值。
### 🔧 技术改进
#### 缺口大小计算
- **修复**:看涨缺口现在正确计算为 `当前低点 - 之前高点`
- **修复**:看跌缺口现在正确计算为 `之前低点 - 当前高点`
- 所有缺口大小现在均为正值
#### 连续MIG逻辑
- **修复**:连续缺口现在测量整个序列的总大小,而非单个K线的缺口
- **增强**:Z-Score随着序列延伸动态更新
- **优化**:历史数据仅在序列开始时更新,防止数据污染
### 🎨 使用技巧
1. **高波动市场**:降低阈值至0.5-0.8以看到更多双FPL
2. **震荡市场**:保持默认1.05或提高至1.5
3. **测试**:关闭"Show CC MIG"选项可查看单个缺口的调试数据
4. **最佳实践**:等待K线确认后再分析调试数值
### 📈 为什么使用Z-Score?
传统方法对所有缺口一视同仁。Z-Score方法的优势:
- ✅ 自动适应市场波动性
- ✅ 统计学识别真正的异常缺口
- ✅ 在低波动期减少噪音
- ✅ 提供客观的、数据驱动的FPL决策
### 🐛 Bug修复
- 修复了看涨MIG的负值缺口大小计算错误
- 修复了连续缺口序列的Z-Score计算逻辑
- 修复了历史数组更新时机问题
- 改进了调试变量的实时更新可见性
---
## 📝 Version History
**v8.0** - Z-Score Intelligence Update
- Introduced statistical Z-Score analysis for FPL decisions
- Added 6 debug indicators
- Fixed gap size calculation bugs
- Unified single/consecutive MIG logic
**Previous versions:**
- v7.6 - Bug fixes for follow-through bars
- v7.5 - Customizable tooltip
- v7.0-7.4 - PaintBar system and various improvements
---
## 💡 Feedback & Support
If you find this indicator helpful, please:
- ⭐ **Star** this indicator on TradingView
- 💬 **Comment** with your settings and results
- 📊 **Share** your charts using #MIGIndicator
For questions or bug reports, please leave a comment below.
---
## ⚠️ Disclaimer
This indicator is for educational purposes only. Always do your own research and risk management. Past performance does not guarantee future results.
---
**Happy Trading! 📈**
เอกสารเผยแพร่
---Update: Smoother Experience & Enhanced Stability / 体验升级与稳定性优化
English
This update is all about making the indicator faster and more reliable for your daily trading.
* 🚀 Performance Boost: We've upgraded the internal engine. The indicator now loads faster and runs smoother on your charts, even with long history data.
* 🎯 Higher Precision: Optimized the calculation logic for "Micro Gaps" and "Micro Channels" to ensure signals are generated with maximum stability.
* 🛡️ Reliability: Fixed potential edge-case issues to ensure consistent performance across different timeframes and assets.
Enjoy the cleaner and faster trading experience!
---
中文
本次更新致力于为您带来更流畅、更可靠的使用体验。
* 🚀 性能大幅提升: 我们升级了指标的内核引擎。现在加载速度更快,运行更丝滑,即使在加载大量历史数据时也不会卡顿。
* 🎯 精度优化: 优化了“微缺口 (MIG)”和“微通道 (Micro Channel)”的计算逻辑,确保信号生成的稳定性。
* 🛡️ 可靠性增强: 修复了潜在的极端情况问题,确保在不同周期和交易品种下表现一致。
祝您交易愉快!
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน