Indicator · Pine Script v5 · Own pane

JRD v2 Jump Risk Differential

by AssetWhisper

An indicator in a separate pane that separates realised variance from jump-robust bipower variation over a rolling window, and shows the share of recent volatility attributed to jumps.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code94
Settings9inputs
LicenceMPL-2.0
Last update7 weeks ago10 Sep 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

94 lines of Pine Script v5 from indicators/JRD_Jump_Risk_Differential.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

JRD_Jump_Risk_Differential.pine
//@version=5
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AssetWhisper — https://assetwhisper.com/indicators/
// ============================================================================
//  JRD v2 — Jump Risk Differential (RV vs Bipower Variation + test BNS)
//  Idea: la varianza realizada RV = Σr² recoge difusión + saltos; la variación
//  bipotencia BV = (π/2)·Σ|r_t||r_{t-1}| es robusta a saltos (Barndorff-Nielsen &
//  Shephard, 2004). La parte de saltos es max(0, RV − BV) y su cuota (RV−BV)/RV
//  mide cuánta volatilidad reciente viene de discontinuidades. v2 añade el
//  estadístico ratio de BNS (con cuarticidad tripotencia) para saber si los saltos
//  son estadísticamente significativos, detecta saltos barra a barra con σ robusta
//  y devuelve puertas de decisión: evitar rupturas / entradas tras compresión.
// ============================================================================
indicator("JRD v2 — Jump Risk Differential", shorttitle="JRD v2", overlay=false)

n        = input.int(30, "Window (bars)", minval=10, maxval=200)
smoothL  = input.int(3, "Smoothing", minval=1, maxval=10)
highTh   = input.float(0.50, "High jump share", minval=0.2, maxval=0.9, step=0.05)
lowTh    = input.float(0.25, "Low jump share", minval=0.05, maxval=0.5, step=0.05)
zSig     = input.float(1.96, "BNS z significance", minval=1.0, maxval=4.0, step=0.01)
jumpK    = input.float(3.0, "Bar jump threshold (robust σ mult)", minval=1.5, maxval=6.0, step=0.5)
compRank = input.int(25, "Compression: ATR percentile <", minval=5, maxval=50)
rankLen  = input.int(100, "ATR rank lookback", minval=30, maxval=500)
showComp = input.bool(true, "Show RV / BV volatilities", group="Visual")

// === VARIANZA REALIZADA, BIPOWER Y TRIPOWER ===
r  = math.log(close / close[1])
ar = math.abs(r)
rv = ta.sum(r * r, n)
bv = (math.pi / 2) * ta.sum(ar * ar[1], n)
mu43 = 0.8309                                              // 2^(2/3)·Γ(7/6)/Γ(1/2)
tq = n * math.pow(mu43, -3) * ta.sum(math.pow(ar, 4.0 / 3) * math.pow(ar[1], 4.0 / 3) * math.pow(ar[2], 4.0 / 3), n)

jumpShare = rv > 0 ? math.max(0.0, 1 - bv / rv) : 0.0
theta = math.pi * math.pi / 4 + math.pi - 5                // ≈ 0.609
bnsZ  = rv > 0 and bv > 0 ? (1 - bv / rv) / math.sqrt(theta * math.max(1.0, tq / (bv * bv)) / n) : 0.0
share = ta.ema(jumpShare, smoothL)

sigRobust = math.sqrt(bv / n)                              // σ por barra robusta a saltos
isJumpBar = sigRobust > 0 and ar > jumpK * sigRobust
jumpUp    = isJumpBar and r > 0
jumpDn    = isJumpBar and r < 0
jumpCount = ta.sum(isJumpBar ? 1 : 0, n)

// === CLASIFICACIÓN Y PUERTAS ===
highRisk = share >= highTh or (bnsZ >= zSig and share >= lowTh)
lowRisk  = share < lowTh and bnsZ < zSig
riskLevel = highRisk ? 2 : lowRisk ? 0 : 1
riskLabel = highRisk ? "HIGH JUMP RISK" : lowRisk ? "LOW JUMP RISK" : "MODERATE"
riskColor = highRisk ? color.red : lowRisk ? color.green : color.orange

atr = ta.atr(14)
atrRank = ta.percentrank(atr, rankLen)
compressed = atrRank < compRank
avoidBreakouts = highRisk
entryWindow    = compressed and lowRisk and share <= share[1]

// === VISUAL ===
hline(highTh * 100, "High share", color=color.new(color.red, 60), linestyle=hline.style_dashed)
hline(lowTh * 100, "Low share", color=color.new(color.green, 60), linestyle=hline.style_dashed)
hline(0, "Zero", color=color.gray)
plot(share * 100, "Jump share % (RV-BV)/RV", color=riskColor, linewidth=2)
plot(bnsZ * 10, "BNS z ×10", color=color.new(color.purple, 40), linewidth=1)
hline(19.6, "z = 1.96 (×10)", color=color.new(color.purple, 70), linestyle=hline.style_dotted)
plot(showComp ? math.sqrt(rv / n) * 100 * 10 : na, "RV vol/bar % ×10", color=color.new(color.blue, 70), linewidth=1)
plot(showComp ? sigRobust * 100 * 10 : na, "BV vol/bar % ×10", color=color.new(color.teal, 70), linewidth=1)
bgcolor(highRisk ? color.new(color.red, 92) : entryWindow ? color.new(color.blue, 90) : compressed ? color.new(color.gray, 94) : na, title="State")
plotshape(jumpUp, "Jump up", style=shape.triangleup, location=location.bottom, color=color.new(color.green, 30), size=size.tiny)
plotshape(jumpDn, "Jump down", style=shape.triangledown, location=location.top, color=color.new(color.red, 30), size=size.tiny)
plotshape(entryWindow and not entryWindow[1], "Entry window", style=shape.circle, location=location.bottom, color=color.aqua, size=size.small, text="ENTRY")
plotshape(highRisk and not highRisk[1], "Avoid breakouts", style=shape.xcross, location=location.top, color=color.red, size=size.small, text="AVOID")
plot(riskLevel, "JRD risk level (export: 0 low / 1 mod / 2 high)", display=display.none)

var table t = table.new(position.top_right, 2, 7, bgcolor=color.new(color.black, 60))
table.cell(t, 0, 0, "JUMP RISK", text_color=color.white, text_size=size.small)
table.cell(t, 1, 0, riskLabel, bgcolor=color.new(riskColor, 30), text_color=color.white, text_size=size.small)
table.cell(t, 0, 1, "Jump share", text_color=color.white, text_size=size.small)
table.cell(t, 1, 1, str.tostring(share * 100, "#.#") + "%", text_color=riskColor, text_size=size.small)
table.cell(t, 0, 2, "BNS z", text_color=color.white, text_size=size.small)
table.cell(t, 1, 2, str.tostring(bnsZ, "#.##") + (bnsZ >= zSig ? " ✱" : ""), text_color=bnsZ >= zSig ? color.red : color.gray, text_size=size.small)
table.cell(t, 0, 3, "Jumps in window", text_color=color.white, text_size=size.small)
table.cell(t, 1, 3, str.tostring(jumpCount) + " / " + str.tostring(n), text_color=color.white, text_size=size.small)
table.cell(t, 0, 4, "σ robust / bar", text_color=color.white, text_size=size.small)
table.cell(t, 1, 4, str.tostring(sigRobust * 100, "#.##") + "%", text_color=color.teal, text_size=size.small)
table.cell(t, 0, 5, "ATR rank", text_color=color.white, text_size=size.small)
table.cell(t, 1, 5, str.tostring(atrRank, "#") + (compressed ? " (compressed)" : ""), text_color=compressed ? color.aqua : color.gray, text_size=size.small)
table.cell(t, 0, 6, "Gate", text_color=color.white, text_size=size.small)
table.cell(t, 1, 6, avoidBreakouts ? "AVOID BREAKOUTS" : entryWindow ? "ENTRY WINDOW" : "NEUTRAL", text_color=avoidBreakouts ? color.red : entryWindow ? color.aqua : color.gray, text_size=size.small)

// === ALERTAS ===
alertcondition(highRisk and not highRisk[1], "JRD High jump risk", "JRD v2: jump risk turned HIGH - avoid breakouts")
alertcondition(entryWindow and not entryWindow[1], "JRD Entry window", "JRD v2: compression with low jump risk - entry window")
alertcondition(isJumpBar, "JRD Jump bar", "JRD v2: jump bar detected (|r| above robust sigma threshold)")
alertcondition(bnsZ >= zSig and bnsZ[1] < zSig, "JRD Significant jumps", "JRD v2: BNS test significant - jumps present in window")

Overview

JRD v2 Jump Risk Differential adds a Barndorff-Nielsen and Shephard style significance test, bar-by-bar jump detection using a robust volatility scale, and high and low jump-share thresholds. A compression check based on ATR percentile is also included. Window, smoothing and thresholds are inputs.

Details

Published by

AssetWhisper on GitHub

Draws

Separate pane below the chart

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
Window (bars)int30n
Smoothingint3smoothL
High jump sharefloat0.50highTh
Low jump sharefloat0.25lowTh
BNS z significancefloat1.96zSig
Bar jump threshold (robust σ mult)float3.0jumpK
Compression: ATR percentile <int25compRank
ATR rank lookbackint100rankLen
Show RV / BV volatilitiesbooltrueshowComp
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 indicator calculates the distribution of close-to-close percentage changes using rate of change on closing prices. It bins percentage changes into intervals of 0.25 percent increments from negative to positive values and plots a normalized cumulative hist

Indicator v4 Volatility & bands
Updated 12 days ago · GPL-3.0 GitHub repository of Close-to-Close % Change Distribution

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

Indicator v5 TrendVolatility & bands
Updated 1 year ago · MPL-2.0 GitHub repository of Trend Following Setup - Sideways Market Skipper
330 stars

This indicator plots candle range and open-to-close movement as percentages in a separate pane. Range is the high-low difference divided by the low, and change is the close-open difference divided by the open. Both series draw as columns. Teal columns show ran

Indicator v5 Volatility & bands
Updated 2 months ago · None stated GitHub repository of Percent & Volatility [Alorse]

Mojito v3 Strategy

by namuan
318 stars

The Mojito v3 Strategy indicator evaluates volatility term structure by calculating the ratio between front-month and second-month VIX futures contracts. It smooths this ratio using a configurable median filter and compares the result against user-defined uppe

Indicator v5 Volatility & bands
Updated 2 months ago · MIT GitHub repository of Mojito v3 Strategy

Function - Logistic Equation

by ricardosantos79
261 stars

Calculates dynamic modeling values by applying a mathematical logistic differential equation to price change over a specified lookback length. It measures price momentum relative to the recent high-low price range. The script plots positive and negative logist

Indicator v5 Oscillators & momentumVolatility & bands
Updated 4 years ago · None stated GitHub repository of Function - Logistic Equation
228 stars

This indicator detects a Bollinger Band squeeze when the bands sit inside Keltner Channels, marking low volatility. It plots red dots during a squeeze and green dots when the bands are outside, in a separate pane. An optional histogram shows momentum as the cl

Indicator v6 Volatility & bandsOscillators & momentum
Updated 3 months ago · None stated GitHub repository of Bollinger Band Squeeze Detector

More Volatility & bands 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