This indicator identifies significant volume spikes on daily and weekly timeframes by comparing current volume against moving averages over user-defined lookback periods.
1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
87 lines of Pine Script v5 from volume_spike.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
volume_spike.pine
// @version=5
indicator("ezVolume Spike Detector", overlay=false)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Identifies significant volume increases on both daily and weekly timeframes.
// By ezPappi
//Key Features:
//Identifies volume spikes on daily timeframes (current chart)
//Detects volume spikes on weekly timeframes
//Highlights when both daily and weekly spikes occur simultaneously
//Customizable thresholds and lookback periods
//Visual indicators with color-coded volume bars
//Labels for significant volume events
//Alert conditions for trading notifications
//Parameters you can adjust:
//Daily Volume Threshold (default: 2.0x average volume)
//Weekly Volume Threshold (default: 1.5x average volume)
//Daily Average Lookback period (default: 20 bars)
//Weekly Average Lookback period (default: 10 weeks)
//Visual Indicators:
//Blue columns: Daily volume spikes
//Red columns: Weekly volume spikes
//Purple columns: When both daily and weekly spikes occur together
//Labels for significant events
// User inputs for customization
dailyThreshold = input.float(2.0, "Daily Volume Threshold", minval=1.0, step=0.1,tooltip="Minimum ratio of current volume to average volume to consider as a spike (daily)")
weeklyThreshold = input.float(1.5, "Weekly Volume Threshold", minval=1.0, step=0.1,tooltip="Minimum ratio of current volume to average volume to consider as a spike (weekly)")
dailyLookback = input.int(20, "Daily Average Lookback", minval=5, maxval=100,tooltip="Number of bars to consider for daily moving average")
weeklyLookback = input.int(10, "Weekly Average Lookback", minval=3, maxval=50,tooltip="Number of bars to consider for weekly moving average")
// Function to detect volume spikes
volumeSpikeDetector(threshold, lookback) =>
avgVolume = ta.sma(volume, lookback)
volumeRatio = volume / avgVolume
volumeRatio >= threshold ? volumeRatio : 0
// Calculate daily volume ratios (on current timeframe)
dailyVolumeRatio = volumeSpikeDetector(dailyThreshold, dailyLookback)
dailySpike = dailyVolumeRatio > 0
// Request weekly volume data and calculate weekly spikes
weeklyVolume = request.security(syminfo.tickerid, "W", volume)
weeklyAvgVolume = request.security(syminfo.tickerid, "W", ta.sma(volume, weeklyLookback))
weeklyVolumeRatio = weeklyVolume / weeklyAvgVolume
weeklySpike = weeklyVolumeRatio >= weeklyThreshold
// Determine the current bar's weekly position (to avoid repeating alerts)
isFirstBarOfWeek = timeframe.isintraday and (dayofweek != dayofweek[1])
// Colors for visualization
dailySpikeColor = color.new(color.blue, 20)
weeklySpikeColor = color.new(color.red, 20)
bothSpikeColor = color.new(color.purple, 20)
noSpikeColor = color.new(color.gray, 60)
// Set plot colors based on spike conditions
plotColor = dailySpike and weeklySpike ? bothSpikeColor :
dailySpike ? dailySpikeColor :
weeklySpike ? weeklySpikeColor :
noSpikeColor
// Plot the daily volume ratio as a histogram
dailyPlot = plot(dailyVolumeRatio, title="Daily Volume Ratio", color=plotColor, style=plot.style_columns)
// Horizontal threshold line
plot(dailyThreshold, title="Daily Threshold", color=color.new(color.blue, 50), style=plot.style_line)
// Labels for significant volume spikes
if dailySpike and weeklySpike
label.new(bar_index, dailyVolumeRatio, text="MAJOR\nVOLUME\nSPIKE",
style=label.style_label_down, color=bothSpikeColor, textcolor=color.white, size=size.small)
else if dailySpike and dailyVolumeRatio >= dailyThreshold * 1.5 // Only show labels for very significant daily spikes
label.new(bar_index, dailyVolumeRatio, text="DAILY\nSPIKE",
style=label.style_label_down, color=dailySpikeColor, textcolor=color.white, size=size.small)
else if weeklySpike and isFirstBarOfWeek
label.new(bar_index, dailyVolumeRatio > 0 ? dailyVolumeRatio : dailyThreshold,
text="WEEKLY\nSPIKE", style=label.style_label_down,
color=weeklySpikeColor, textcolor=color.white, size=size.small)
// Alerts
alertcondition(dailySpike, title="Daily Volume Spike", message="Daily volume spike detected!")
alertcondition(weeklySpike and isFirstBarOfWeek, title="Weekly Volume Spike", message="Weekly volume spike detected!")
alertcondition(dailySpike and weeklySpike, title="Major Volume Spike", message="Both daily and weekly volume spikes detected!")
Overview
ezVolume Spike Detector plots the daily volume ratio as a histogram in a separate pane, with blue columns for daily spikes, red for weekly spikes, and purple for simultaneous events. Horizontal lines mark the customizable thresholds. The script adds labels for major spikes and supports alert conditions. Inputs allow adjustment of daily threshold, weekly threshold, daily lookback, and weekly lookback. It draws solely on the current chart without repainting or using future data.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Daily Volume Threshold
float
2.0
dailyThreshold
Weekly Volume Threshold
float
1.5
weeklyThreshold
Daily Average Lookback
int
20
dailyLookback
Weekly Average Lookback
int
10
weeklyLookback
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.
Calculates the standard Money Flow Index (MFI) oscillator alongside an exponential moving average signal line in a separate pane. The script visually highlights trend conditions through dynamic ribbon filling, optional difference histogram bars, and overbought
This indicator plots a Supertrend-based trend-following setup in a separate pane and skips conditions it treats as a sideways market. A volatility range is built from an ATR value, with RMA, SMA, EMA, or WMA smoothing, or from a fixed point distance. Optional
Range Volume Change compares volume inside a chosen session window with the same window on the previous day and plots that change as a percentage. It accumulates volume during the window and, when enabled, volume outside it, drawing growing columns in a separa
This indicator builds a footprint of estimated buy and sell volume across price rows and plots it in a separate pane. It fills rows from bar low to high, stores volume per row, and draws buy and sell volume boxes, volume-profile boxes, row labels, and cumulati
This indicator measures directional momentum by evaluating candlestick body proportions and volume over a user-defined lookback window. It computes the ratio of candle body to total range, weights the cumulative value by volume and absolute body size, and dete
This indicator builds an aggregate oscillator in a separate pane. It scales open, high, low, close, and volume into a 0 to 1 range, then averages scaled readings from MACD, a MACD histogram, RSI, stochastic, CCI, momentum, OBV, a directional index, volume-weig