// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// PF probe 26 — volume-spike + ATR breakout
// Purpose: parity test for combined ta.sma(volume) spike detection and
// ta.atr-derived close-distance breakout confirmation.
//
//@version=6
strategy("Volume Breakout", overlay=true, initial_capital=1000000, process_orders_on_close=false, pyramiding=1, commission_type=strategy.commission.percent, commission_value=0, slippage=0, default_qty_type=strategy.fixed, default_qty_value=1)
// === Inputs ===
volLen = input.int(20, "Volume MA Length", minval=5)
volMult = input.float(1.5, "Volume Spike Multiplier", step=0.1)
atrLen = input.int(14, "ATR Length", minval=1)
atrMult = input.float(1.0, "ATR Breakout Multiplier", step=0.1)
// === Indicators ===
volMA = ta.sma(volume, volLen)
volSpike = volume > volMA * volMult
atrVal = ta.atr(atrLen)
// === Price breakout with volume confirmation ===
priceBreakUp = close > close[1] + atrVal * atrMult
priceBreakDown = close < close[1] - atrVal * atrMult
// === Signals ===
longCond = priceBreakUp and volSpike
shortCond = priceBreakDown and volSpike
if longCond
strategy.entry("Long", strategy.long)
if shortCond
strategy.entry("Short", strategy.short)
// === Exit when volume dries up ===
if strategy.position_size > 0 and close < close[1] and volume < volMA
strategy.close("Long")
if strategy.position_size < 0 and close > close[1] and volume < volMA
strategy.close("Short")