Indicator · Pine Script v5 · On the chart

Intraday Gap Detector

by might-tree

This indicator calculates the percentage price gap between the current bar open and the previous bar close on the price chart.

View on GitHub

GitHub stars4on the repository
Pine versionv5runs as is
Lines of code23
Settings0inputs
LicenceNone statedfile: MPL-2.0
Last update3 years ago2 Aug 2023

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

23 lines of Pine Script v5 from Indicators/Intraday_Gap_Detector.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Intraday_Gap_Detector.pine
//Run the following Script on PINE EDITOR or any platform supporting Pine Script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © might-tree

//@version=5
indicator("Intraday Gap Detector", overlay=true)
size = 0.2
days = 30

gap_width = math.round(((((open - close[1]) / close[1])*100)*100)/100)

var x = close

if math.abs(gap_width) > size and (timenow - time) < 1000*60*60*24*days
    x := close[1]
    
    if gap_width < 0
        line.new(bar_index-1, x, bar_index, x, extend=extend.right, style= line.style_arrow_left, color=color.rgb(27, 146, 63), width=1)
        label.new(timenow, x, xloc= xloc.bar_time, text="Gap Up", color=color.rgb(27, 146, 63), textcolor=color.white)
    else
        line.new(bar_index-1, x, bar_index, x, extend=extend.right, style= line.style_arrow_left, color=color.rgb(171,8,8), width=1)
        label.new(timenow, x, xloc= xloc.bar_time, text="Gap Down", color=color.rgb(171, 8, 8), textcolor=color.white)

Overview

When the absolute gap exceeds a hardcoded threshold of 0.2 percent within the past 30 days, it draws an extended horizontal line at the previous close level and places an informative label at the current time coordinate. The threshold settings and lookback window are fixed in the script code without configurable input fields.

Details

Published by

might-tree on GitHub

Draws

On the price chart

Markets

Stocks

Timeframes

M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Sideway Zones Live

by dearvn
257 stars

Sideway Zones Live is an overlay indicator that estimates inner and outer sideways bands from recent highs and lows with a rational quadratic kernel. It tracks swing pivots over a loopback period and counts bars that remain between the outer high and low. Afte

Indicator v5 TrendSupport & resistance
Updated 7 weeks ago · None stated GitHub repository of Sideway Zones Live
228 stars

This indicator plots dynamic support and resistance levels on the price chart. It detects pivot highs and lows using the pivot length and tracks touches to build strength-based levels. Support and resistance zones appear as colored boxes while lines mark key l

Indicator v6 Support & resistanceBreakout
Updated 3 months ago · None stated GitHub repository of Dynamic Support & Resistance
220 stars

This indicator identifies High Of Low Price (HOLP) and Low Of High Price (LOHP) candlestick setups based on price extremes over a specified lookback period. A HOLP signal triggers when the current bar closes above the high of a recent session low, whereas a LO

Indicator v5 Candlestick patternsBreakout
Updated 1 year ago · None stated GitHub repository of Candlestick Patterns - HOLP-LOHP

Donchian Channels (DC)

by mihakralj
99 stars

This indicator calculates and plots Donchian Channels directly on the price chart. It determines the highest high and lowest low over a user-selected lookback period using an optimized monotonic deque algorithm, as well as a middle basis line computed as their

Indicator v6 Volatility & bandsSupport & resistance
Updated 4 weeks ago · Apache-2.0 GitHub repository of Donchian Channels (DC)

Lows from New Highs

by be-thomas
65 stars

This indicator tracks bar lows during consecutive rising highs using Pine Script arrays. When at least four lows accumulate or the price breaches the minimum low in the stack, the script sorts the recorded lows in ascending order and flushes them. It plots up

Indicator v4 Support & resistanceBreakout
Updated 6 days ago · GPL-3.0 GitHub repository of Lows from New Highs

This indicator tracks smart money market structure directly on the price chart. It calculates dual-period swing highs and swing lows to detect Changes of Character (CHoCH), Breaks of Structure (BOS), inducements, and liquidity sweeps. When structural levels ar

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · Apache-2.0 GitHub repository of Market Structure with Inducements & Sweeps [LuxAlgo]

More Support & resistance scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers