Indicator · Pine Script v6 · On the chart

Stella's Volume Spike Detector

by stella-entry

This indicator compares each bar's volume with a simple moving average of volume and flags a spike when volume exceeds that average by a user-set multiplier.

View on GitHub

GitHub stars3on the repository
Pine versionv6current
Lines of code68
Settings6inputs
LicenceMIT
Last update8 months ago22 Feb 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

68 lines of Pine Script v6 from indicators/volume-spike-detector.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

volume-spike-detector.pine
//@version=6
indicator("Stella's Volume Spike Detector", overlay=true, max_labels_count=500)

// ============================================
// パラメーター設定
// ============================================
lookbackPeriod = input.int(20, "ルックバック期間", minval=5, maxval=100)
spikeMultiplier = input.float(2.0, "急増判定倍率", minval=1.0, maxval=5.0, step=0.1)

// 表示設定
showLabels = input.bool(true, "ラベルを表示")
showBackground = input.bool(true, "背景色を表示")

// 色
bullishColor = input.color(color.new(color.green, 0))
bearishColor = input.color(color.new(color.red, 0))

// ============================================
// ボリューム計算
// ============================================
avgVolume = ta.sma(volume, lookbackPeriod)
isSpike = volume > avgVolume * spikeMultiplier

// 価格方向
isBullish = close > open
isBearish = close < open

// スパイクタイプ
bullishSpike = isSpike and isBullish
bearishSpike = isSpike and isBearish

// ============================================
// 表示
// ============================================
// 背景色
bgcolor(showBackground and bullishSpike ? color.new(color.green, 85) : showBackground and bearishSpike ? color.new(color.red, 85) : na)

// ラベル
if showLabels and bullishSpike
    label.new(bar_index, high, "🟢 VOL x" + str.tostring(volume / avgVolume, "#.#"), 
              color=color.new(color.green, 80), textcolor=color.white, 
              style=label.style_label_down, size=size.tiny)

if showLabels and bearishSpike
    label.new(bar_index, low, "🔴 VOL x" + str.tostring(volume / avgVolume, "#.#"), 
              color=color.new(color.red, 80), textcolor=color.white, 
              style=label.style_label_up, size=size.tiny)

// ============================================
// アラート条件
// ============================================
alertcondition(bullishSpike, "買いボリューム急増", "買いボリュームが平均の{{ticker}}倍に急増")
alertcondition(bearishSpike, "売りボリューム急増", "売りボリュームが平均の{{ticker}}倍に急増")
alertcondition(isSpike, "ボリューム急増", "ボリュームが平均の{{ticker}}倍に急増")

// ============================================
// 情報パネル(オプション)
// ============================================
var table infoPanel = table.new(position.top_right, 2, 3, bgcolor=color.new(color.black, 90), border_width=1)

if barstate.islast
    table.cell(infoPanel, 0, 0, "平均ボリューム", text_color=color.white, text_size=size.small)
    table.cell(infoPanel, 1, 0, str.tostring(avgVolume, "#,###"), text_color=color.white, text_size=size.small)
    table.cell(infoPanel, 0, 1, "現在ボリューム", text_color=color.white, text_size=size.small)
    table.cell(infoPanel, 1, 1, str.tostring(volume, "#,###"), text_color=color.white, text_size=size.small)
    table.cell(infoPanel, 0, 2, "倍率", text_color=color.white, text_size=size.small)
    table.cell(infoPanel, 1, 2, str.tostring(volume / avgVolume, "#.#") + "x", 
               text_color=isSpike ? color.green : color.white, text_size=size.small)

Overview

An up candle is treated as bullish and a down candle as bearish. It paints the chart background and optional labels on the price chart, and a small table shows average volume, current volume, and the ratio. Lookback length, spike multiplier, labels, background, and colors are adjustable. It does not place trades or define exits.

Details

Published by

stella-entry on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Volume, Breakout, Screeners & dashboards

Markets

Any symbol

Timeframes

Any timeframe

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.

Settings

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

SettingTypeDefaultVariable
ルックバック期間int20lookbackPeriod
急増判定倍率float2.0spikeMultiplier
ラベルを表示booltrueshowLabels
背景色を表示booltrueshowBackground
bullishColorcolorcolor.new(color.green, 0)bullishColor
bearishColorcolorcolor.new(color.red, 0)bearishColor
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

2 stars

Calculates 20-day Average Daily Range percentage, multi-month performance metrics, opening gap size, and relative volume to identify Kristjan Kullamägi style Breakout and Episodic Pivot setups. When conditions are satisfied on the price chart, it flags candles

Indicator v6 BreakoutVolume
Updated 4 months ago · Custom licence GitHub repository of Qullamaggie Breakout / EP Flags

The Market Tail Risk Detector evaluates market fragility and compression to identify environments preceding volatile price moves. It calculates a composite tail risk score ranging from 0 to 100 based on realized volatility percentiles, volatility of volatility

Indicator v6 Volatility & bandsBreakout Repaints
Updated 3 months ago · Apache-2.0 GitHub repository of Market Tail Risk Detector (Quiet → Explosive)
2 stars

This indicator analyzes volume character and market structure in a separate chart pane. It color-codes volume bars to identify institutional accumulation, distribution, climax volume, and volume dry-up conditions during volatility contraction patterns. The scr

Indicator v5 VolumeTrend
Updated 4 months ago · None stated GitHub repository of TJ Essentials - Daily Swing

This overlay indicator screens a pasted list of up to forty symbols and draws a table on the price chart. It classifies bullish or bearish setups from the percent change between the current candle and the candle 250 bars back, then shows RSI with a simple movi

Indicator v5 Oscillators & momentumVolume
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers