OPEN-SOURCE SCRIPT

Bipower Jump Detector [forexobroker]

333
🔶 OVERVIEW

Bipower Jump Detector [forexobroker] implements the Barndorff-Nielsen jump test: realized variance (RV) captures both diffusion and jump risk, while bipower variation (BV) — built from products of adjacent absolute returns scaled by pi/2 — is jump-robust. Their non-negative difference isolates the jump component J; the standardized Jump-Z statistic tests whether that difference is significant. When Jump-Z exceeds the cutoff (default 1.96, 95% one-sided), the script enters in the direction of the largest absolute return inside the window. The unique angle is using a peer-reviewed jump test rather than ad-hoc bar-size thresholds.

🔶 ALGORITHM

1. Log-returns r_t = log(close / close[1]) are computed each bar.
2. Realized variance RV = sum of r_t^2 over the window (default 20).
3. Bipower variation BV = (pi/2) * sum of |r_t| * |r_{t-1}| over the window (jump-robust by construction).
4. Jump component J = max(RV - BV, 0) is plotted as a histogram.
5. Jump-Z = sqrt(N) * (RV - BV) / sqrt(theta * BV^2 * 0.5) with theta = pi^2/4 + pi - 5 (Barndorff-Nielsen and Shephard, 2006).
6. Direction is the sign of the largest |r_k| inside the window — the dominant jump bar drives the entry side.
7. Significant jump = Jump-Z > threshold (default 1.96); a 15-bar cooldown and position state flip-prevention stop the same jump cluster from firing multiple entries.

🔶 SIGNAL LOGIC

- Buy: Jump-Z above threshold AND dominant return in the window is positive AND session filter passes AND position is not already long AND cooldown bars elapsed AND barstate.isconfirmed.
- Sell: Jump-Z above threshold AND dominant return in the window is negative AND session filter passes AND position is not already short AND cooldown bars elapsed AND barstate.isconfirmed.

The Z test is the gate, the dominant return is the direction.

🔶 INPUTS

- Jump Calculation group: window length default 20, significance Z default 1.96 (raise to 2.58 for stricter 99%).
- Signal Logic group: cooldown bars default 15.
- Filters group: session restriction (default 0000-2400).
- Visual group: dashboard, 3-layer glow, jump markers, jump component color, Jump-Z color, buy and sell colors.

🔶 ALERTS

BJD Buy, BJD Sell, BJD Any Signal, BJD Significant, BJD Jump Up, BJD Jump Down, BJD Z Rising, BJD J Rising, BJD High Jump Ratio, BJD Quiet Diffusion, BJD Webhook JSON.

🔶 LIMITATIONS

- The Barndorff-Nielsen test was designed for high-frequency intraday returns; on daily timeframes the diffusion-jump decomposition is harder to interpret and BV becomes a less precise diffusion proxy.
- Bipower variation needs at least two adjacent non-zero absolute returns; a window with one or two zero returns inflates Jump-Z artificially.
- The direction comes from the single dominant return in the window — when two large opposite jumps occur back-to-back, the entry side may not reflect the most recent move.
- Defaults are tuned for liquid crypto and intraday futures; thin instruments with frequent zero-volume bars produce noisy BV estimates.
- The Z formula uses a simplified variance approximation (theta * BV^2 * 0.5); under extreme volatility the small-sample distribution deviates from the normal approximation.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.