Strategy vault / Trend following
Chande Kroll Stop
Dear TV''ers, Hereby a script where i created a simple strategy using the underappreciated chande kroll stop indicator. Short signal is when the close crosses under the orange line and a long signal is generated upon…
Dear TV''ers,
Hereby a script where i created a simple strategy using the underappreciated chande kroll stop indicator. Short signal is when the close crosses under the orange line and a long signal is generated upon a crossover of a close candle of the blue line. Additionally you have the option to filter using ADX the minimize getting rekt in a choppy market.
good luck trading!
backtest

Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_int_1 | 10 | p |
| v_input_int_2 | true | x |
| v_input_int_3 | 9 | q |
| v_input_1 | 14 | ADX Smoothing |
| v_input_2 | 14 | DI Length |
| v_input_int_4 | 20 | minimum ADX threshold for signal |
Source Pine Script
//@version=5
strategy(title = "Chande Kroll Stop", overlay=true)
p = input.int(10, minval=1)
x = input.int(1, minval=1)
q = input.int(9, minval=1)
first_high_stop = ta.highest(high, p) - x * ta.atr(p)
first_low_stop = ta.lowest(low, p) + x * ta.atr(p)
stop_short = ta.highest(first_high_stop, q)
stop_long = ta.lowest(first_low_stop, q)
plot(stop_long, color=color.blue)
plot(stop_short, color=color.orange)
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
ADX_sig = input.int(20, title="minimum ADX threshold for signal")
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)
if ta.crossunder(close, stop_long) and sig>ADX_sig
strategy.entry("long", strategy.long)
if ta.crossover(close, stop_short) and sig>ADX_sig
strategy.entry("short", strategy.short)Published by ChaoZhang on the FMZ strategy square · last modified 2022-05-09. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Chande-Kroll-Stop.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Adaptive Risk Management Strategy Based on Dynamic ATR and Moving Average CrossoverPine Script · Trend following · 2h
- Dual EMA Filtered ATR Adaptive Trend Following StrategyPine Script · Trend following · 1h
- Dual Moving Average Trend Detection with Volatility Based Stop Loss StrategyPine Script · Trend following · 1d
- Dynamic EMA Trend Detection with ATR Threshold StrategyPine Script · Trend following · 1h
- Dynamic Multi Indicator Trend Recognition Strategy with Triple Sync AnalysisPine Script · Trend following · 1d
- Extreme version of Noros Trend Moving Averages StrategyPine Script · Trend following · 1h