Strategy · Pine Script v6 · On the chart

PF probe kkb-probe-integration

by pineforge-4pass· code credited to PineForge contributors 2026

This strategy combines a one-dimensional Kalman filter with an EMA midline and ATR breakout bands.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code68
Settings5inputs
LicenceApache-2.0
Last update7 days ago23 Oct 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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

68 lines of Pine Script v6 from validation/composite-kkb-integration-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// PF probe kkb-probe-integration — Kalman + breakout + margin-100%
// Clean-room: written from validation goal, not from source.
//
// Purpose: composes the three surfaces isolated by `kkb-probe-01..03`
// (1-D Kalman filter, EMA-mid + ATR breakout band, `margin_long=100,
// margin_short=100` broker-emulator semantics) into one strategy. Long
// when Kalman trends up AND price breaks the upper band; short when
// Kalman trends down AND price breaks the lower band. Exit when the
// opposite breakout fires. Verifies that the runtime carries Kalman
// state correctly while the broker emulator enforces full-margin sizing.
//
// Validation goal: bit-exact trade list against TradingView's broker
// emulator on the reference 15-minute ETH-USDT-USDT feed.
//
// TV setup: 15m chart, ETH-USDT-USDT (Binance USDT-M Perpetual). Full window
// matching corpus/data/ohlcv_ETH-USDT-USDT_15m.csv. Strategy properties:
// leave defaults from script header. Export "List of trades" → tv_trades.csv.
//@version=6
strategy("PF probe kkb-probe-integration", shorttitle="PF_kkbINT",
     overlay=true, initial_capital=1000000,
     commission_type=strategy.commission.percent, commission_value=0,
     slippage=0, default_qty_type=strategy.fixed, default_qty_value=1,
     pyramiding=1, process_orders_on_close=false,
     margin_long=100, margin_short=100)

// ---- inputs --------------------------------------------------------
float i_q        = input.float(0.001, "Process variance Q",     minval=0.0, step=0.0005)
float i_r        = input.float(0.1,   "Measurement variance R", minval=0.0001, step=0.01)
int   i_band_len = input.int(20,    "Band EMA length", minval=2)
int   i_atr_len  = input.int(14,    "ATR length",      minval=2)
float i_atr_mult = input.float(1.5, "ATR multiplier",  minval=0.1, step=0.1)

// ---- Kalman state -------------------------------------------------
var float x = na
var float p = 1.0

float x_pred = nz(x[1], close)
float p_pred = nz(p[1], 1.0) + i_q
float k_gain = p_pred / (p_pred + i_r)
x := x_pred + k_gain * (close - x_pred)
p := (1 - k_gain) * p_pred

bool kalman_bull = x > nz(x[1], x)
bool kalman_bear = x < nz(x[1], x)

// ---- breakout band ------------------------------------------------
float band  = ta.ema(close, i_band_len)
float vol   = ta.atr(i_atr_len)
float upper = band + vol * i_atr_mult
float lower = band - vol * i_atr_mult

bool break_up   = ta.crossover(close,  upper)
bool break_down = ta.crossunder(close, lower)

// ---- composed gates -----------------------------------------------
bool go_long  = kalman_bull and break_up
bool go_short = kalman_bear and break_down

// ---- order routing -------------------------------------------------
if go_long and strategy.position_size <= 0
    strategy.entry("L", strategy.long, qty=1, comment="integ long")

if go_short and strategy.position_size >= 0
    strategy.entry("S", strategy.short, qty=1, comment="integ short")

Overview

PF probe kkb-probe-integration enters long when the Kalman estimate rises and close crosses above the upper band, and short when the estimate falls and close crosses below the lower band. An opposite breakout closes and reverses the position. Process and measurement variance, band length, ATR length, and ATR multiplier are inputs. It draws on the price chart. Orders use a fixed quantity of one and full margin on both sides. There is no separate stop loss.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge contributors 2026, as written in the script's header

Draws

On the price chart

Markets

Crypto

Timeframes

M15-H1

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

Settings

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

SettingTypeDefaultVariable
Process variance Qfloat0.001i_q
Measurement variance Rfloat0.1i_r
Band EMA lengthint20i_band_len
ATR lengthint14i_atr_len
ATR multiplierfloat1.5i_atr_mult
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

106 stars

This strategy runs on the price chart and enters long when a fast simple moving average crosses above a slow one, and short on the opposite cross, while closing the other side. Entries also need ATR above a filter, a pullback check, a minimum candle-body chang

Strategy v5 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 9:22 5 MIN 15 MIN BANKNIFTY

均线突破交易系统

by tangly1024
76 stars

This strategy trades long breakouts of a fast and a slow moving average on the price chart. It opens a long position when price crosses above either average, using a percentage of equity as size. It reduces the position by a set share when the high reaches the

Strategy v5 TrendMoving averages
Updated 5 months ago · None stated GitHub repository of 均线突破交易系统
16 stars

This strategy plots Donchian channels, trailing stops, and profit targets directly on the price chart. It enters breakout trades using a 55-bar Donchian channel and sizes positions according to an ATR-based risk percentage per unit. The system adds units as pr

Strategy v6 TrendBreakout
Updated 12 months ago · None stated GitHub repository of Seykota Alt 10: Profit Targets
4 stars

This strategy executes trend-following trades based on Bollinger Band breakouts confirmed by a long-term moving average filter. A long position opens when the price crosses above the upper Bollinger Band, provided the band spread meets a minimum threshold and

Strategy v5 Volatility & bandsTrend
Updated 2 years ago · None stated GitHub repository of Bollinger Trend - Strategy V1
4 stars

The Keltner Channel Strategy is a breakout system plotted directly on the main price chart. It calculates upper and lower channel bands around an exponential or simple moving average using ATR, True Range, or bar range multiplied by a specified factor. A long

Strategy v5 TrendVolatility & bands
Updated 5 months ago · None stated GitHub repository of Keltner Channel Strategy

More Trend 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