Indicator · Pine Script v5 · On the chart

Storm Gauge — Vol Regime + Position Size

by Miles-Deutscher

This overlay indicator estimates realized volatility from log returns and annualizes it with a user-chosen periods-per-year setting.

View on GitHub

GitHub stars42on the repository
Pine versionv5runs as is
Lines of code79
Settings14inputs
LicenceMIT
Last update3 months ago15 Jul 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

79 lines of Pine Script v5 from pine-script/storm-gauge.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

storm-gauge.pine
//@version=5
indicator("Storm Gauge — Vol Regime + Position Size", shorttitle="STORM GAUGE", overlay=true)

volLen      = input.int(20,  "Realized vol window (days)",   minval=5,   maxval=100)
pctileLen   = input.int(252, "Percentile lookback (days)",   minval=60,  maxval=1000)
periodsYear = input.int(365, "Periods per year (365 crypto / 252 stocks)", minval=1)
targetVol   = input.float(15.0, "Target vol % (annualized)", minval=1.0, maxval=200.0, step=0.5)
baseSize    = input.float(10000, "Baseline position ($)", minval=100, step=500)
maxLev      = input.float(2.0,  "Max size multiplier",       minval=0.5, maxval=10.0, step=0.25)
minSize     = input.float(0.25, "Min size multiplier",       minval=0.05, maxval=1.0, step=0.05)
calmTh      = input.float(33.0, "Calm threshold (percentile)",  minval=1, maxval=49)
stormTh     = input.float(67.0, "Storm threshold (percentile)", minval=51, maxval=99)
simpleMode  = input.bool(true,  "Simple labels (plain English)")
showBands   = input.bool(true,  "Show vol bands on price")
showTint    = input.bool(true,  "Show storm background tint")
tintTransp  = input.int(94, "Storm tint transparency", minval=80, maxval=99)
showTable   = input.bool(true,  "Show gauge panel")

ret       = math.log(close / close[1])
dailyVol  = ta.stdev(ret, volLen)
annVol    = dailyVol * math.sqrt(periodsYear) * 100.0

cnt = 0
obs = 0
for i = 1 to pctileLen
    if not na(annVol[i])
        obs := obs + 1
        cnt := cnt + (annVol > annVol[i] ? 1 : 0)
volPctile = obs == pctileLen ? 100.0 * cnt / obs : na

isCalm  = volPctile < calmTh
isStorm = volPctile > stormTh
regimeTxt   = isStorm ? "STORM" : isCalm ? "CALM" : "NORMAL"
regimeColor = isStorm ? color.new(#d62728, 0) : isCalm ? color.new(#0a7d38, 0) : color.new(#8a8a8a, 0)

rawSize  = annVol > 0 ? targetVol / annVol : minSize
sizeMult = math.min(math.max(rawSize, minSize), maxLev)
dollarSize = baseSize * sizeMult

actionTxt   = sizeMult < 0.4 ? "ENTER AT QUARTER SIZE" : sizeMult < 0.75 ? "ENTER AT HALF SIZE" : sizeMult <= 1.25 ? "ENTER AT NORMAL SIZE" : "ENTER AT LARGER SIZE"
actionColor = sizeMult < 0.75 ? color.new(#d62728, 15) : sizeMult <= 1.25 ? color.new(#3a4048, 0) : color.new(#0a7d38, 15)

lblVol    = simpleMode ? "Market violence" : "Realized vol"
lblPct    = simpleMode ? "vs past year"    : "Percentile (1y)"
lblRegime = simpleMode ? "Weather"         : "Regime"
lblSize   = simpleMode ? "If you enter: size" : "If you enter: size @ target"

basis = ta.ema(close, volLen)
band  = basis * dailyVol * math.sqrt(volLen)
upper = basis + band
lower = basis - band
pU = plot(showBands ? upper : na, "Vol band upper", color=color.new(#5b7fa6, 45), linewidth=1)
pL = plot(showBands ? lower : na, "Vol band lower", color=color.new(#5b7fa6, 45), linewidth=1)
fill(pU, pL, color=isStorm ? color.new(#d62728, 93) : color.new(#5b7fa6, 97))

bgcolor(showTint and isStorm ? color.new(#d62728, tintTransp) : na)

var table gauge = table.new(position.top_right, 2, 8, border_width=1, bgcolor=color.new(#101418, 10), border_color=color.new(#2a2f36, 0))

if barstate.islast and showTable
    table.cell(gauge, 0, 0, "STORM GAUGE", text_color=color.white, text_size=size.small, bgcolor=color.new(#1a1f26, 0))
    table.cell(gauge, 1, 0, "live", text_color=color.new(#8a8a8a, 0), text_size=size.tiny, bgcolor=color.new(#1a1f26, 0))
    table.cell(gauge, 0, 1, lblVol, text_color=color.new(#c9c9c9, 0), text_size=size.small)
    table.cell(gauge, 1, 1, str.tostring(annVol, "#.#") + "% vs " + str.tostring(targetVol, "#.#") + "% limit", text_color=color.white, text_size=size.small)
    table.cell(gauge, 0, 2, lblPct, text_color=color.new(#c9c9c9, 0), text_size=size.small)
    table.cell(gauge, 1, 2, str.tostring(volPctile, "#") + "%", text_color=color.white, text_size=size.small)
    table.cell(gauge, 0, 3, lblRegime, text_color=color.new(#c9c9c9, 0), text_size=size.small)
    table.cell(gauge, 1, 3, regimeTxt, text_color=color.white, text_size=size.small, bgcolor=regimeColor)
    table.cell(gauge, 0, 4, lblSize, text_color=color.new(#c9c9c9, 0), text_size=size.small)
    table.cell(gauge, 1, 4, str.tostring(sizeMult, "#.##") + "x", text_color=color.white, text_size=size.normal, bgcolor=sizeMult < 0.75 ? color.new(#d62728, 20) : sizeMult > 1.25 ? color.new(#0a7d38, 20) : color.new(#3a4048, 0))
    table.cell(gauge, 0, 5, "If you enter: $ (on $" + str.tostring(baseSize, "#,###") + ")", text_color=color.new(#c9c9c9, 0), text_size=size.small)
    table.cell(gauge, 1, 5, "$" + str.tostring(dollarSize, "#,###"), text_color=color.white, text_size=size.normal)
    table.cell(gauge, 0, 6, "Action", text_color=color.new(#c9c9c9, 0), text_size=size.small)
    table.cell(gauge, 1, 6, actionTxt, text_color=color.white, text_size=size.small, bgcolor=actionColor)
    table.cell(gauge, 0, 7, "Says how much — never when. Entries are your strategy's job", text_color=color.new(#8a8a8a, 0), text_size=size.tiny)
    table.cell(gauge, 1, 7, "", text_size=size.tiny)

alertcondition(isStorm and not isStorm[1], "Storm regime begins", "Vol percentile crossed into STORM — size down")
alertcondition(not isStorm and isStorm[1], "Storm regime ends", "Vol percentile left STORM — normal sizing")

Overview

Storm Gauge — Vol Regime + Position Size ranks that volatility against a trailing lookback to label calm, normal, or storm regimes, and it converts a target volatility into a capped position-size multiplier and dollar amount. Main inputs change the vol window, percentile thresholds, target volatility, and size limits. It draws optional volatility bands around an EMA on the price chart, tints storm bars, and shows a gauge table. It does not place trades or set stops.

Details

Published by

Miles-Deutscher on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Volatility & bands, 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
Realized vol window (days)int20volLen
Percentile lookback (days)int252pctileLen
Periods per year (365 crypto / 252 stocks)int365periodsYear
Target vol % (annualized)float15.0targetVol
Baseline position ($)float10000baseSize
Max size multiplierfloat2.0maxLev
Min size multiplierfloat0.25minSize
Calm threshold (percentile)float33.0calmTh
Storm threshold (percentile)float67.0stormTh
Simple labels (plain English)booltruesimpleMode
Show vol bands on pricebooltrueshowBands
Show storm background tintbooltrueshowTint
Show all 14 settings
SettingTypeDefaultVariable
Storm tint transparencyint94tintTransp
Show gauge panelbooltrueshowTable
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

This overlay indicator plots a Supertrend from an ATR length and factor, four exponential moving averages, and a selectable VWAP or TWAP taken from a chosen timeframe on the price chart. It also shows MACD and stochastic with adjustable lengths, smoothing, ver

Indicator v5 Oscillators & momentumMoving averages
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup: Vijay Thakare Option Buying Scalping Setup
330 stars

This multi-symbol indicator evaluates a combined trading condition across up to 40 user-defined symbols. It processes MACD bullish crossovers, RSI thresholds, Bollinger Band boundaries, and DMI/ADX trend filters using security calls. When buy or sell criteria

Indicator v5 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of Multi MACD + BB + RSI [Alorse]

Pricing Table

by namuan
318 stars

This indicator calculates theoretical options contract values and in-the-money probabilities using historical realized volatility across multiple standard deviations. It displays these metrics in a table overlay directly on the price chart. Users can adjust th

Indicator v4 Volatility & bandsScreeners & dashboards
Updated 2 months ago · MIT GitHub repository of Pricing Table
218 stars

This indicator maps market structure and supply and demand zones on the price chart. It marks validated and optional unvalidated swing highs and lows using a pivot length and extra confirmation bars. Consolidation and impulse moves are measured against ATR to

Indicator v6 SMC / ICT / price actionSupport & resistance Repaints
Updated 3 months ago · None stated GitHub repository of Market Structure + Supply/Demand
200 stars

Storm Gauge calculates annualized realized volatility and compares it against a historical percentile lookback window to classify market volatility regimes into calm, normal, or storm conditions. Based on a target volatility input, it calculates dynamic positi

Indicator v5 Volatility & bandsScreeners & dashboards
Updated 3 months ago · MIT GitHub repository of Storm Gauge — Vol Regime + Position Size

8zz反指標v2

by hansai-art
121 stars

The 8zz Contrarian Indicator plots reverse sentiment trading signals directly on the price chart based on tracked retail post activity. It generates bullish signals during retail panic and bearish signals during market euphoria. The indicator features adjustab

Indicator v6 Moving averagesOscillators & momentum
Updated 3 months ago · None stated GitHub repository of 8zz反指標v2

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