Gap Trader

mortdiggiddy Updated   
  • Plot the most recent 20 gaps based on custom session info.
  • The session can be customized with a start time and an end time.
  • The previous open, high, low, close are only from the price during the session specified.
  • A gap line will stop printing the moment the gap is filled.
  • For CME futures, the session must be offset by one hour for Central time. I use the official cash close of 16:15 EST (yes, not 16:00) as this is the TRUE close when options go offline. Every day CME futures take a break between 16:15 - 16:30 EST for settlement, and then again from 17:00 - 18:00 EST.
  • To offset CME futures you must subtract an hour, the official NYSE hours for futures: 0830-1515, this translates to 9:30 AM EST - 4:15 PM EST.
  • For information about the probability of a previous day's gap being filled by the NYSE close:
Release Notes:
  • Update to version 4 pinescript.
  • Gaps now include date labels and the price!
Release Notes:
  • Updated gap fill mechanism.
  • Added final price label when a gap is filled for reference.
  • Added a "Gap Filled" alertcondition when any previous gap in the last 20 sessions is filled.
  • Gaps are only shown for the previous 20 sessions for performance reasons in pinescript.
Release Notes:
  • Added member features.
Release Notes:
  • Resolved the issue with 24x7 session on stocks where there is no extended sesssion.
  • Added additional icons to show the unfilled gaps.
  • Added label showing the unfilled or premarket close that must touch during the next session, or a gap will be generated.
  • Major improvements to gap calculations.
  • Option to use the "settlement close" instead of the last value prescribed by the session window. This is useful for stocks and future that have a separate settlement close reported by the exchange.
Release Notes:
  • Fixed issue with n/a values for the recent Pine 4.0 development updates.
Release Notes:
  • Major UI performance improvements.
  • Last 20 gaps stored in memory.
  • Options for coloring added using color palette.
  • New gaps are now distinguished from continuing unfilled gaps.
  • Fixed issue where the session window never closes (usually happened with stock symbols not using extended hours).
Release Notes:
  • Added timezone feature. Use the timezone to match the session window. For example, when using the cash session of the NYSE as 0930-1600, the correct timezone would be GMT-4. However, if your Trading View settings are set for GMT+0 for London time, then the session window should be set to 1430-2100. The timezone feature is used to specify the local time with respect to the session window.
Release Notes:
  • Updated American time zones to use daylight savings time where appropriate.

Invite-only script

Access to this script is restricted to users authorized by the author and usually requires payment. You can add it to your favorites, but you will only be able to use it after requesting permission and obtaining it from its author. Contact mortdiggiddy for more information, or follow the author's instructions below.

TradingView does not suggest paying for a script and using it unless you 100% trust its author and understand how the script works. In many cases you can find a good open-source alternative for free in our Community Scripts.


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.

Author's instructions

Contact @mortdiggiddy or email the website for further instructions.

Want to use this script on a chart?

Warning: please read before requesting access.