Indicator · Pine Script v4 · On the chart

Intraday Volume Swings

by theonetrade· code credited to rumpypumpydumpy

Intraday Volume Swings tracks multi-bar price and volume movements directly on the price chart.

View on GitHub

GitHub stars34on the repository
Pine versionv4older, still runs
Lines of code198
Settings5inputs
LicenceMIT
Last update2 weeks ago8 Nov 2026

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

198 lines of Pine Script v4 from assets/indicator/bit-exact/intraday_volume_swings_dFY6oRQi.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

intraday_volume_swings_dFY6oRQi.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rumpypumpydumpy

//@version=4
study("Intraday Volume Swings", overlay = true)

mark_swings         = input(true,   title = "Mark all volume swings?")
mark_new_day        = input(true,   title = "Mark first bar of a new day?")
mark_greater_swings = input(true,   title = "Mark daily lower/higher swings?")
plot_current        = input(false,  title = "Display levels as they form?")
region_must_close   = input(true,   title = "Must close in region to trigger alert?")

// Necessary variables to construct conditions
// -----------------------------------------------------------------------------
new_day                 = change(time("D")) != 0
increasing_volume       = volume > volume[1]
lower_low               = low < low[1]
higher_high             = high > high[1]
high_bar                = increasing_volume and higher_high                     // Base conditions of increasing volume and a higher high / lower low
low_bar                 = increasing_volume and lower_low
swing_low               = low_bar and low_bar[1] and low_bar[2]                 // Minimum Swing Conditions of three bars of increasing volume and higher high / lower low
swing_high              = high_bar and high_bar[1] and high_bar[2]
confirmed_swing_low     = not swing_low and swing_low[1]                        // Condition to indicate the end of a swing
confirmed_swing_high    = not swing_high and swing_high[1]
hh3                     = highest(high, 3)
ll3                     = lowest(low, 3)
// -----------------------------------------------------------------------------

// Variables to track the top and bottom of the swing region for the duration of the swing
// -----------------------------------------------------------------------------
float   swing_low_top = na
float   swing_low_bottom = na
float   swing_high_top = na
float   swing_high_bottom = na
// -----------------------------------------------------------------------------


// Initial Swing conditions
// -----------------------------------------------------------------------------
if swing_low and not swing_low[1]                                               // Indicates a new 3 bar swing low
    swing_low_top       := hh3                                                  // Sets the top and bottom to the highest high / lowest low of the three bars
    swing_low_bottom    := ll3
else if swing_low and swing_low[1]                                              // Indicates both the current bar and the previous bar are both volume swings. This condition will remain true until the swing is complete
    swing_low_top       := max(swing_low_top[1], high)                          // Modify the top and bottom swing levels if they are higher/lower on the new bar
    swing_low_bottom    := min(swing_low_bottom[1], low)

if swing_high and not swing_high[1]
    swing_high_top      := hh3
    swing_high_bottom   := ll3
else if swing_high and swing_high[1]
    swing_high_top      := max(swing_high_top[1], high)
    swing_high_bottom   := min(swing_high_bottom[1], low)
// -----------------------------------------------------------------------------


// Variables to determine the lowest swing low and highest swing high for the day
// -----------------------------------------------------------------------------
var float   daily_swing_low_top = na
var float   daily_swing_low_bottom = na
var float   daily_swing_high_top = na
var float   daily_swing_high_bottom = na
// -----------------------------------------------------------------------------


// Conditional statements to determine the lowest swing low for the day
// -----------------------------------------------------------------------------

// Daily Lowest Swing Low
// -----------------------------------------------------------------------------

if new_day and not swing_low and not confirmed_swing_low                        // If the first bar of the day is not part of an existing swing or the last bar of the previous day is not part of a completed swing then reset for the day
    daily_swing_low_top     := na
    daily_swing_low_bottom  := na

if new_day and swing_low                                                        // If the first bar is part of an unfinished swing, continue tracking levels established the previous day
    daily_swing_low_top     := swing_low_top
    daily_swing_low_bottom  := swing_low_bottom

if new_day and confirmed_swing_low                                              // Returns true if the first bar of the day is not part of a volume swing, but the last bar of the previous day is. Rolls over the swing levels to the current day
    daily_swing_low_top     := swing_low_top[1]
    daily_swing_low_bottom  := swing_low_bottom[1]

if not new_day and confirmed_swing_low and na(daily_swing_low_bottom)           // If it isn't the first bar of the day AND the current bar indicates a swing low is finished AND it is the FIRST swing low of the day. Store levels
    daily_swing_low_top     := swing_low_top[1]
    daily_swing_low_bottom  := swing_low_bottom[1]

if not new_day and confirmed_swing_low and not na(daily_swing_low_bottom) and swing_low_bottom[1] < daily_swing_low_bottom
    daily_swing_low_top     := swing_low_top[1]                                 // If it isn't the first bar of the day AND the current bar indicates a swing low is finished AND it is NOT the FIRST swing of the day AND ...
    daily_swing_low_bottom  := swing_low_bottom[1]                              // the current swing is LOWER than the previous then store the new swing's levels (otherwise the previous and lower swing's levels remain)
// -----------------------------------------------------------------------------


// Daily Highest Swing High
// -----------------------------------------------------------------------------
if new_day and not swing_high and not confirmed_swing_high
    daily_swing_high_top     := na
    daily_swing_high_bottom  := na

if new_day and swing_high
    daily_swing_high_top     := swing_high_top
    daily_swing_high_bottom  := swing_high_bottom

if new_day and confirmed_swing_high
    daily_swing_high_top     := swing_high_top[1]
    daily_swing_high_bottom  := swing_high_bottom[1]

if not new_day and confirmed_swing_high and na(daily_swing_high_bottom)
    daily_swing_high_top     := swing_high_top[1]
    daily_swing_high_bottom  := swing_high_bottom[1]

if not new_day and confirmed_swing_high and not na(daily_swing_high_top) and swing_high_top[1] > daily_swing_high_top
    daily_swing_high_top     := swing_high_top[1]
    daily_swing_high_bottom  := swing_high_bottom[1]
// -----------------------------------------------------------------------------

// Final Calculations
// -----------------------------------------------------------------------------

valid_chart = timeframe.isintraday and not na(volume)                           // Is the chart intraday and have volume (eg non index)?

// Variables for yesterday's levels
float prev_swing_low_top = na
float prev_swing_low_bottom = na
float prev_swing_high_top = na
float prev_swing_high_bottom = na

// Variables for the day before yesterday's levels
float prev_swing_low_top2 = na
float prev_swing_low_bottom2 = na
float prev_swing_high_top2 = na
float prev_swing_high_bottom2 = na

// Retrieve yesterday's Lowest Swing Low and Highest Swing High
prev_swing_low_top      := valuewhen(new_day, daily_swing_low_top[1],       0)  // This is also equivalent to :
prev_swing_low_bottom   := valuewhen(new_day, daily_swing_low_bottom[1],    0)  // prev_swing_low_top := new_day ? daily_swing_low_top[1] : prev_swing_low_top[1]
prev_swing_high_top     := valuewhen(new_day, daily_swing_high_top[1],      0)
prev_swing_high_bottom  := valuewhen(new_day, daily_swing_high_bottom[1],   0)

prev_swing_low_bottom2  := valuewhen(new_day, daily_swing_low_bottom[1],    1)  // However to obtain older values from previous days it is easier to use valuewhen
prev_swing_high_top2    := valuewhen(new_day, daily_swing_high_top[1],      1)


lower_swing_low     = prev_swing_low_bottom < prev_swing_low_bottom2            // Check if we have a higher daily swing high / lower daily swing low
higher_swing_high   = prev_swing_high_top > prev_swing_high_top2
// -----------------------------------------------------------------------------



// Plots and labels
// -----------------------------------------------------------------------------

current_swing_low_top_plot      = plot(valid_chart and plot_current ? daily_swing_low_top : na,     style = plot.style_circles, color = color.maroon,   transp = 50, linewidth = 1)
current_swing_low_bottom_plot   = plot(valid_chart and plot_current ? daily_swing_low_bottom : na,  style = plot.style_circles, color = color.maroon,   transp = 50, linewidth = 1)
current_swing_high_top_plot     = plot(valid_chart and plot_current ? daily_swing_high_top : na,    style = plot.style_circles, color = color.green,    transp = 50, linewidth = 1)
current_swing_high_bottom_plot  = plot(valid_chart and plot_current ? daily_swing_high_bottom : na, style = plot.style_circles, color = color.green,    transp = 50, linewidth = 1)

swing_low_top_plot      = plot(valid_chart ? prev_swing_low_top : na,       color = #00000000, title = "Swing Low Upper Plot")
swing_low_bottom_plot   = plot(valid_chart ? prev_swing_low_bottom : na,    color = #00000000, title = "Swing Low Lower Plot")
swing_high_top_plot     = plot(valid_chart ? prev_swing_high_top : na,      color = #00000000, title = "Swing High Upper Plot")
swing_high_bottom_plot  = plot(valid_chart ? prev_swing_high_bottom : na,   color = #00000000, title = "Swing High Lower Plot")

fill(swing_low_top_plot,    swing_low_bottom_plot,  color = color.red,   transp = 70)
fill(swing_high_top_plot,   swing_high_bottom_plot, color = color.lime,  transp = 70)

plotshape(mark_swings ? confirmed_swing_low : na,   style = shape.triangleup,   location = location.belowbar, size = size.tiny, color = color.red,  title = "Swing Low")
plotshape(mark_swings ? confirmed_swing_high : na,  style = shape.triangledown, location = location.abovebar, size = size.tiny, color = color.lime, title = "Swing High")

higher_swing_label  = mark_greater_swings and higher_swing_high ? label.new(x = time, y = avg(prev_swing_high_bottom, prev_swing_high_top), xloc = xloc.bar_time, color = color.green,  textcolor = color.white, style = label.style_label_left, size = size.small, text = "Higher Swing High") : na
lower_swing_label   = mark_greater_swings and lower_swing_low   ? label.new(x = time, y = avg(prev_swing_low_bottom, prev_swing_low_top),   xloc = xloc.bar_time, color = color.red,    textcolor = color.white, style = label.style_label_left, size = size.small, text = "Lower Swing Low") : na
label.delete(higher_swing_label[1])
label.delete(lower_swing_label[1])

bgcolor(new_day and mark_new_day ? color.yellow : #00000000)

warning_label = not valid_chart ? label.new(x = time, y = close, xloc = xloc.bar_time, color = color.red, textcolor = color.white, style = label.style_label_left, size = size.normal, text = "Warning!!!\nIntraday Timeframes with Volume Only") : na
label.delete(warning_label[1])
// -----------------------------------------------------------------------------


// Alerts
// -----------------------------------------------------------------------------

// Alerts for the previous day's highest/lowest swings
if region_must_close ? open[1] < prev_swing_high_bottom and close[1] >= prev_swing_high_bottom : open < prev_swing_high_bottom and high >= prev_swing_high_bottom
    alert("Pushing up into yesterday's swing high region", alert.freq_once_per_bar)

if region_must_close ? open[1] > prev_swing_low_top and close[1] <= prev_swing_low_top : open > prev_swing_low_top and low <= prev_swing_low_top
    alert("Pushing down into yesterday's swing low region", alert.freq_once_per_bar)

// Alerts for the current day's highest/lowest swings
if region_must_close ? open[1] < daily_swing_high_bottom and close[1] >= daily_swing_high_bottom :  open < daily_swing_high_bottom and high >= daily_swing_high_bottom
    alert("Pushing up into current swing high region", alert.freq_once_per_bar)

if region_must_close ? open[1] > daily_swing_low_top and close[1] <= daily_swing_low_top : open > daily_swing_low_top and low <= daily_swing_low_top
    alert("Pushing down into current swing low region", alert.freq_once_per_bar)

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

Overview

Intraday Volume Swings detects volume swings defined by consecutive bars of increasing volume with sequential higher highs or lower lows. The script calculates the top and bottom price bounds for these swing regions and highlights daily extreme swing levels. Configurable options allow users to mark individual volume swings, identify daily session resets, toggle daily extreme swings, and render levels dynamically as they form.

Details

Published by

theonetrade on GitHub

Code credit

rumpypumpydumpy, as written in the script's header

Type

Indicator, Pine Script v4

Draws

On the price chart

Markets

Any symbol

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.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Mark all volume swings?booltruemark_swings
Mark first bar of a new day?booltruemark_new_day
Mark daily lower/higher swings?booltruemark_greater_swings
Display levels as they form?boolfalseplot_current
Must close in region to trigger alert?booltrueregion_must_close
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

VP

by dearvn
257 stars

This indicator calculates and plots a session-based volume profile directly on the price chart. It maps volume distribution across price levels, highlighting key structural reference points including the Point of Control, Value Area High, and Value Area Low. C

Indicator v5 VolumeSupport & resistance
Updated 2 months ago · None stated GitHub repository of VP

Midnight VWAP

by TradersPost
228 stars

The Midnight VWAP indicator calculates and overlays two distinct Volume Weighted Average Price (VWAP) lines on the price chart based on customizable session timeframes. It tracks an overnight or pre-market session alongside regular trading hours, resetting cal

Indicator v6 Moving averagesSessions & time
Updated 4 months ago · None stated GitHub repository of Midnight VWAP

Moon Dev GEX Arrows

by moondevonyt
98 stars

This overlay indicator plots option strike walls and an optional session VWAP on the price chart for SPY or ES. It spaces major strikes by the selected instrument, draws a set number of strikes on each side, and marks wall-trap and sweep events after a cooldow

Indicator v5 Support & resistanceSessions & time
Updated 2 months ago · Custom licence GitHub repository of Moon Dev GEX Arrows

This overlay indicator draws a volume profile for a chosen trading session directly on the price chart. It plots the point of control, value area high and low, an optional value area box, a live zone, and a session box with labels. Users select Tokyo, London,

Indicator v5 Sessions & timeVolume
Updated 2 months ago · None stated GitHub repository of Sessions & VP with prev session VP & daily/weekly opens

LoD Intraday Entry

by ChartsLector
41 stars

This overlay indicator marks the current day's low and a suggested entry zone a fraction of daily ATR below that low. It compares daily volume with a volume moving average, plots daily SMA and EMA distance, and draws an optional ATR-width price cloud. Labels c

Indicator v6 Support & resistanceVolatility & bands
Updated 4 weeks ago · None stated GitHub repository of LoD Intraday Entry

RS: Market Profile

by agejevasv
12 stars

This indicator plots a Market Profile on the price chart using time-price opportunity letters or symbols. It marks the point of control, a configurable value area, and the initial balance, and it can highlight a volume-profile point of control and session VWAP

Indicator v5 VolumeSupport & resistance
Updated 2 years ago · None stated GitHub repository of RS: Market Profile

More Volume 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