OPEN-SOURCE SCRIPT
已更新 Microgaps (plots-only, 4-channel, same-day only)

Purpose:
This indicator visually highlights 3-bar price gaps on your chart, showing clear visual structure for gap zones without lag or diagonal artifacts.
It draws two outer lines (top and bottom of the gap) for every valid 3-bar gap, and optionally a midline when the gap is considered “large.”
⚙️ How it works
A bull gap is detected when the current bar’s low is higher than the high from two bars ago (low > high[2]).
A bear gap is detected when the current bar’s high is lower than the low from two bars ago (high < low[2]).
The lines are centered at the middle bar of the 3-bar sequence.
Gaps are only drawn within the same trading day to avoid false overnight gaps.
To prevent overlapping artifacts, up to four concurrent gap channels can be drawn efficiently using GPU-friendly plot() lines.
🔵 Midline logic
The midline (center of the gap) is only displayed when the gap’s vertical size is “large” relative to recent volatility.
“Large” means the gap height is greater than a user-defined fraction of the average bar range over the past N bars.
Example: if the average 8-bar range = 2 points, and the threshold = 0.3, then only gaps larger than 0.6 points will show the midline.
🧩 Parameters
Setting Description
Bull Gap Color / Width Style of bullish gaps (top and bottom lines).
Bear Gap Color / Width Style of bearish gaps (top and bottom lines).
Mid Gap Color / Width Style of the optional midline (shown only when “large”).
Large Gap — Lookback (bars) Number of bars used to calculate the average range (default: 8).
Large Gap — Size vs Avg Range Fraction of the average range that defines a “large” gap (default: 0.5). Set lower (e.g. 0.3) to show more midlines.
💡 Tips
Set threshold lower (0.2–0.4) for more midlines, higher (0.6–1.0) to highlight only extreme gaps.
Works best on intraday timeframes (1-min to 30-min).
Fully GPU-efficient — can scroll back thousands of bars without lag.
This indicator visually highlights 3-bar price gaps on your chart, showing clear visual structure for gap zones without lag or diagonal artifacts.
It draws two outer lines (top and bottom of the gap) for every valid 3-bar gap, and optionally a midline when the gap is considered “large.”
⚙️ How it works
A bull gap is detected when the current bar’s low is higher than the high from two bars ago (low > high[2]).
A bear gap is detected when the current bar’s high is lower than the low from two bars ago (high < low[2]).
The lines are centered at the middle bar of the 3-bar sequence.
Gaps are only drawn within the same trading day to avoid false overnight gaps.
To prevent overlapping artifacts, up to four concurrent gap channels can be drawn efficiently using GPU-friendly plot() lines.
🔵 Midline logic
The midline (center of the gap) is only displayed when the gap’s vertical size is “large” relative to recent volatility.
“Large” means the gap height is greater than a user-defined fraction of the average bar range over the past N bars.
Example: if the average 8-bar range = 2 points, and the threshold = 0.3, then only gaps larger than 0.6 points will show the midline.
🧩 Parameters
Setting Description
Bull Gap Color / Width Style of bullish gaps (top and bottom lines).
Bear Gap Color / Width Style of bearish gaps (top and bottom lines).
Mid Gap Color / Width Style of the optional midline (shown only when “large”).
Large Gap — Lookback (bars) Number of bars used to calculate the average range (default: 8).
Large Gap — Size vs Avg Range Fraction of the average range that defines a “large” gap (default: 0.5). Set lower (e.g. 0.3) to show more midlines.
💡 Tips
Set threshold lower (0.2–0.4) for more midlines, higher (0.6–1.0) to highlight only extreme gaps.
Works best on intraday timeframes (1-min to 30-min).
Fully GPU-efficient — can scroll back thousands of bars without lag.
版本注释
Purpose:This indicator visually highlights 3-bar price gaps on your chart, showing clear visual structure for gap zones without lag or diagonal artifacts.
It draws two outer lines (top and bottom of the gap) for every valid 3-bar gap, and optionally a midline when the gap is considered “large.”
⚙️ How it works
A bull gap is detected when the current bar’s low is higher than the high from two bars ago (low > high[2]).
A bear gap is detected when the current bar’s high is lower than the low from two bars ago (high < low[2]).
The lines are centered at the middle bar of the 3-bar sequence.
Gaps are only drawn within the same trading day to avoid false overnight gaps.
To prevent overlapping artifacts, up to four concurrent gap channels can be drawn efficiently using GPU-friendly plot() lines.
🔵 Midline logic
The midline (center of the gap) is only displayed when the gap’s vertical size is “large” relative to recent volatility.
“Large” means the gap height is greater than a user-defined fraction of the average bar range over the past N bars.
Example: if the average 8-bar range = 2 points, and the threshold = 0.3, then only gaps larger than 0.6 points will show the midline.
🧩 Parameters
Setting Description
Bull Gap Color / Width Style of bullish gaps (top and bottom lines).
Bear Gap Color / Width Style of bearish gaps (top and bottom lines).
Mid Gap Color / Width Style of the optional midline (shown only when “large”).
Large Gap — Lookback (bars) Number of bars used to calculate the average range (default: 8).
Large Gap — Size vs Avg Range Fraction of the average range that defines a “large” gap (default: 0.5). Set lower (e.g. 0.3) to show more midlines.
💡 Tips
Set threshold lower (0.2–0.4) for more midlines, higher (0.6–1.0) to highlight only extreme gaps.
Works best on intraday timeframes (1-min to 30-min).
Fully GPU-efficient — can scroll back thousands of bars without lag.
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。