OPEN-SOURCE SCRIPT

Taiyoz Gaps

151
1. Purpose
Tyoz Gaps highlights “gaps” between yesterday’s close and today’s open directly on your chart. A gap occurs when the opening price is significantly above or below the prior bar’s close. By drawing persistent boxes around each gap, you can instantly see where price left a void and monitor when (or if) that void gets completely filled.

2. Gap Detection Logic
Threshold: A gap is only detected if the open-to-previous-close difference exceeds a user-defined “Minimal Deviation” (percentage of the 14-bar average high-low range).

Direction:

Gap Up: today’s open > yesterday’s close

Gap Down: today’s open < yesterday’s close

3. Box Drawing
For each detected gap, the script draws a rectangular box spanning from yesterday’s close level to today’s open level.

Border & Fill Colors are configurable separately for up-gaps and down-gaps.

Boxes extend to the right as new bars form.

4. Display & Filtering Options
Show Gap Up / Show Gap Down toggles let you hide bullish or bearish gaps independently.

Max Number of Gaps: Limits how many boxes remain on-screen; oldest boxes are removed when the limit is exceeded.

Limit Max Gap Trail Length: Optionally force-close any gap box after a given number of bars, even if unfilled.

5. Closing Logic
Full-Fill Only: A gap box stays visible until price fully “fills” it—i.e., for an up-gap, price must exceed the top edge (yesterday’s close); for a down-gap, price must cross below the bottom edge.

Once filled, the box is removed and a “Gap Closed” alert flag is set.

6. Labels & Alerts
Each active gap can optionally show a label at the gap’s lower edge containing:

Absolute size (in price points) and percentage of the gap

Bar count since the gap formed

Label Text Color and Label Text Size are both user-configurable.

Two built-in alertcondition()s fire when a new gap appears or when a gap closes.

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.