Strategy library

Hull Kaufman SuperTrend Cloud strategy in Pine Script

A cloud of three lines – Kaufman adaptive average, its Hull average and a Supertrend – that the price has to break.

Kaufman adaptive moving average · Hull moving average · Supertrend · long only · by SnarkyPuppy · Mozilla Public License 2.0

What its backtest shows

Best of 225 settings: +99.63% · picked in real time: +71.52%

Both over the same months (May 2022 – Oct 2026): the best setting chosen afterwards, and the walk-forward – a setting picked every few months from the months before, the way you could have picked it at the time.

Binance BTC/USDT 4h · Apr 18, 2020 – Nov 13, 2026 · commission 0.1% per order, slippage 2 ticks · 225 settings tested

The verdict

In the walk-forward, picking by past results ended above 99% of random picks from the same settings (only 9 windows). With no real edge, about 1 to 2% of backtests end at least this far above the random picks (PineTester's calibration of Oct 17, 2026). Part of the lead can come from picking settings that trade less and so pay fewer fees or less slippage.

The checks in plain words

Check on a period the pick did not use
On Nov 23, 2024 – Nov 13, 2026 (the last 30%, not used by this pick): −22.13%, rank 53 of 225 settings. Typical setting there: −44.56%. Buy & hold there: −29.94%.
Without its 5 best positions
Without its 5 best positions (of 274), the same setting would have made +138.81% instead of +867.62%.
Walk-forward
Picking, every 6 months, the setting with the best return-to-drawdown ratio over the previous 24 months ended above 99% of 20,000 random picks and above the median setting. Only 9 windows, so the test has little power. Over the same 54 months: walk-forward +71.52% (switching costs included), median setting −33.77%, buy & hold +106.17%; 6 of 9 windows were profitable.
Monte Carlo
In 1 of 20 resampled paths of the walk-forward, the largest drop was more than 71.7% (in half of them more than 47.4%). Monte Carlo rebuilds paths from blocks of this backtest's own days; it describes this backtest, it is not a forecast.

It trades long only and waits in cash when the trend turns down. Picked every few months from the months before, it stayed ahead of most random picks of its settings. It still trailed buy & hold over the same months, and its drops were deep.

A finished backtest in your account, right after the payment: nothing runs again and no credits are used. Paid once by card. Test it on your coin puts this script with its ranges into the order form, where you choose the coin. Your first backtest is free; after that you pay as you go.

Hypothetical results on past data: they describe this backtest, they are not a forecast and not a recommendation.

The rules

  • Enters long when the high crosses above the highest of the three lines.
  • Closes when the low crosses below the lowest of the three lines or the close is below it.
  • Invests the whole account in each trade (100% of equity, set in the code).

What to watch for

  • A full-size position on every trade makes the drawdown the number to check first.
  • The exit sits at the bottom of the cloud: in fast drops it can give back much of the move.

How PineTester judges a backtest, with its sources: how we judge results.

The Pine Script code

The author's code with its licence notice (Mozilla Public License 2.0), with one change marked in the code: the same test conditions for every library strategy in its strategy() line – the whole account per trade (split over the entries where it adds to a position), 0.1% commission per order and 2 ticks slippage; the trading rules are unchanged. Pine Script v5; PineTester converts it to v6 automatically, so results can differ slightly from TradingView.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SnarkyPuppy
// Modified by PineTester (2026-11-14): the same test conditions for every library strategy in strategy(): 100% of equity per entry,
// 0.1% commission per order, 2 ticks slippage, initial capital 10,000. The trading rules are unchanged.
//@version=5
strategy("HKST Cloud", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1, slippage=2)
////////////////nAMA
Lengthkaufman = input(20) 
xPrice = ohlc4
xvnoise = math.abs(xPrice - xPrice[1])
nfastend = 0.666
nslowend = 0.0645
nsignal = math.abs(xPrice - xPrice[Lengthkaufman])
nnoise = math.sum(xvnoise, Lengthkaufman)
nefratio = nnoise != 0? nsignal / nnoise : 0
nsmooth = math.pow(nefratio * (nfastend - nslowend) + nslowend, 2) 
nAMA =  float(0)
nAMA := nz(nAMA[1]) + nsmooth * (xPrice - nz(nAMA[1]))
//plot(nAMA,color=color.red)
///short=input(true)
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
////////hull moving average
hull_len=input(20)
hull= ta.hma(nAMA,hull_len)
///////atr trail
atr_factor=input(2)
atr_period=input(5)
[supertrend, direction] = ta.supertrend(atr_factor,atr_period)
/////////cloud
band1= math.max(supertrend,hull,nAMA)
band2= math.min(supertrend,hull,nAMA)
b1=plot(band1, "band1", color = color.rgb(76, 175, 79, 85), style=plot.style_linebr)
b2=plot(band2, "band2", color = color.rgb(255, 82, 82, 78), style=plot.style_linebr)
fill(b1,b2,color.rgb(12, 50, 186, 75))
longCondition = ta.crossover(high,band1) //or ta.crossover(low,band2)
if (longCondition)
    strategy.entry("Up", strategy.long)
shortCondition =  ta.crossunder(low,band2) or close<band2
if (shortCondition) 
    strategy.close("Up", shortCondition)
  • Double Supertrend – A fast Supertrend opens the trade, a slower second Supertrend decides when it ends.
  • Supertrend + RSI – Trades with the Supertrend direction, but only when the RSI crosses its middle line.
  • Dual Supertrend with MACD – Two Supertrends and the MACD histogram must agree before a trade opens; any one of them turning closes it.
  • Triple Supertrend – Three Supertrends with different settings must all point the same way; the fastest one ends the trade.
  • Chandelier Exit + ZLSMA – A Chandelier Exit turn opens a trade only when the price also crosses a zero-lag least squares average (ZLSMA).

Open-source script by SnarkyPuppy, shown under the Mozilla Public License 2.0. Not a recommendation; neither the author nor TradingView endorses PineTester. Backtests are hypothetical results on past data, not a forecast.