Strategy · Pine Script v6 · On the chart

PF Probe Kanuck-Probe-01-Kama-State

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

This strategy plots the Kaufman Adaptive Moving Average on the price chart as an overlay.

View on GitHub

Repaints

GitHub stars1on the repository
Pine versionv6current
Lines of code54
Settings3inputs
LicenceApache-2.0
Last update5 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

54 lines of Pine Script v6 from validation/composite-kanuck-kama-state-recurrence-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 kanuck-probe-01-kama-state — KAMA stateful adaptive smoothing
// Clean-room: written from validation goal, not from source.
//
// Purpose: isolates a hand-rolled KAMA (Kaufman Adaptive MA) recurrence
// (v6 ships no `ta.kama` built-in, so the math runs explicitly through
// `math.abs`, `math.sum`, and a `var float` state carrier). The smoothing
// constant changes per-bar based on an efficiency ratio derived from
// `length` price changes; engine surface under test is the bar-by-bar
// `kama := kama[1] + sc * (close - kama[1])` update through regime
// transitions where the SC swings fastest.
//
// Validation goal: bit-exact entries on `ta.crossover(close, kama)` and
// exits on `ta.crossunder(close, kama)`. Pass = identical trade list vs
// TradingView.
//
// 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 kanuck-probe-01-kama-state", shorttitle="PF_kan01_KAMA",
     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)

// ---- inputs --------------------------------------------------------
int i_kama_len  = input.int(14, "KAMA length",   minval=2)
int i_kama_fast = input.int(2,  "KAMA fast end", minval=1)
int i_kama_slow = input.int(30, "KAMA slow end", minval=2)

// ---- KAMA (manual recurrence; v6 has no ta.kama built-in) ----------
float change_n  = math.abs(close - close[i_kama_len])
float vol_sum   = math.sum(math.abs(close - close[1]), i_kama_len)
float er        = vol_sum > 0 ? change_n / vol_sum : 0.0
float fast_sc   = 2.0 / (i_kama_fast + 1)
float slow_sc   = 2.0 / (i_kama_slow + 1)
float sc        = math.pow(er * (fast_sc - slow_sc) + slow_sc, 2)
var float kama  = na
kama := na(kama[1]) ? close : kama[1] + sc * (close - kama[1])

// ---- crosses -------------------------------------------------------
bool cross_up   = ta.crossover(close, kama)
bool cross_down = ta.crossunder(close, kama)

// ---- order routing -------------------------------------------------
if cross_up and strategy.position_size <= 0
    strategy.entry("L", strategy.long, qty=1, comment="kama cross up")

if cross_down and strategy.position_size >= 0
    strategy.entry("S", strategy.short, qty=1, comment="kama cross down")

Overview

PF Probe Kanuck-Probe-01-Kama-State generates buy signals on ta.crossover of close above the KAMA and sell signals on ta.crossunder of close below the KAMA. Long entries occur when flat or short, short entries when flat or long. The main settings control KAMA length, fast and slow smoothing constants. It uses fixed position sizing with no stop loss or take profit. The strategy repaints on the live bar.

Details

Published by

pineforge-4pass on GitHub

Code credit

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

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Moving averages, Trend, Mean reversion

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)
  • 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
KAMA lengthint14i_kama_len
KAMA fast endint2i_kama_fast
KAMA slow endint30i_kama_slow
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 mean-reversion strategy plots Bollinger Bands and a long-term moving average directly on the price chart. It enters trades when price candles penetrate the outer Bollinger Bands beyond a user-defined body percentage, anticipating a price reversal. Entries

Strategy v5 Mean reversionVolatility & bands
Updated 2 months ago · None stated GitHub repository of Bollinger Bands Winner PRO [Alorse]

8 Day Run

by hasnocool
106 stars

Inspired by Linda Raschke's strategy for T-note futures, this script identifies extended trends where price remains on one side of a 5-period SMA for more than eight consecutive bars. It enters long on the first pullback below the SMA following an eight-bar bu

Strategy v4 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 8 Day Run

Bollinger Bands Strategy

by cklose2000
105 stars

This strategy generates buy and sell signals based on Bollinger Band crossovers combined with a simple moving average trend filter. It enters a long position when price crosses above the lower band while trading above the SMA filter line, and enters a short po

Strategy v5 Volatility & bandsMoving averages
Updated 1 year ago · None stated GitHub repository of Bollinger Bands Strategy
53 stars

This strategy identifies long entry opportunities based on short-term price pullbacks below a major trend filter. It enters long when three consecutive lower closes occur below the 200-period simple moving average, followed by the current bar closing back abov

Strategy v6 TrendMoving averages
Updated 2 months ago · MPL-2.0 GitHub repository of Ivan Scherman Pattern - TP/SL
13 stars

This strategy evaluates market trend direction using a Noro TrendRibbon and creates a price corridor based on recent moving-average extremes, plotting directly on the price chart. It executes long entries when price dips below the corridor during an upward tre

Strategy v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of Ruckard Noro TrendRibbon G004

VWAP Bounce - Eterna

by EternaHybridExchange
9 stars

This strategy overlays volume-weighted average price deviation bands and an exponential moving average trend filter directly on the price chart. It enters long positions during an uptrend when price recovers above the lower band, and enters short positions in

Strategy v5 Mean reversionTrend
Updated 7 months ago · MIT GitHub repository of VWAP Bounce - Eterna

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers