OPEN-SOURCE SCRIPT

Gap Statistics (Zeiierman)

Overview
The Gap Statistics (Zeiierman) indicator is crafted to monitor, analyze, and visually present price gaps on a trading chart. Price gaps are areas on a chart where the price jumps up or down from the previous close to the next open, creating a "gap" in the normal price pattern. This script delivers an extensive range of statistics related to these gaps, encompassing their size, direction (whether bullish or bearish), frequency of getting filled, as well as the average number of bars it takes for a gap to be filled. The indicator also visually represents the gaps, making it easier for traders to spot and analyze them.

snapshot


How It Works
  • Gap Identification: The script identifies gaps by comparing the open price of a bar to the close price of the previous bar. If there is a discrepancy between the two, it is recognized as a gap.
  • Gap Classification: Once a gap is identified, it is classified based on its size (as a percentage of the previous close price) and direction (bullish or bearish). The gap is then added to a specific category based on its size.
  • Gap Tracking: The script keeps track of all identified gaps using arrays and user-defined types, storing details like their size, direction, and whether they have been filled.
  • Gap Filling: The script continuously monitors the price to check if any previously identified gaps get filled. A gap is considered filled if the price moves back into the gap area.
  • Statistics and Alerts: The script calculates various statistics like the total number of gaps, the number of filled gaps, the average number of bars it takes for a gap to fill, and the percentage of gaps that get filled. It also generates alerts when a new gap is identified or an existing gap gets filled.


How to Use
Gaps are often classified into four main types:
  • Common Gaps: These are not associated with any major news and are likely to get filled quickly.
  • Breakaway Gaps: These occur at the end of a price pattern and signal the beginning of a new trend.
  • Runaway Gaps:Also known as continuation gaps, these occur in the middle of a trend and signal a surge in interest in the stock.
  • Exhaustion Gaps: These occur near the end of a price pattern and signal a final attempt to hit new highs or lows.



The Gap Statistics (Zeiierman) indicator enhances a trader's ability to use gaps in their trading strategy in several ways:

  1. Statistical Analysis: Traders get comprehensive statistics on gaps, such as their size, direction, and how often they get filled.
  2. Performance Tracking: The indicator tracks how many bars it typically takes for a gap to fill, providing traders with an average timeframe for gap closure.


snapshot


Settings
  • Display Gaps: Choose to display "All Gaps," "Active Gaps," or "None."
  • Show Gap Size: Toggle on/off the display of the gap size.



-----------------
Disclaimer

The information contained in my Scripts/Indicators/Ideas/Algos/Systems does not constitute financial advice or a solicitation to buy or sell any securities of any type. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.

All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.

My Scripts/Indicators/Ideas/Algos/Systems are only for educational purposes!
Candlestick analysisgapgapfillgapindicatorgapstatisticsgaptradingstatistics

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer