Strategy vault / Mean reversion
CK Momentum Reversal Stop Loss Strategy
This strategy uses the CK channel to determine price trends and sets dynamic stop loss lines to make reverse operations when price reversal occurs. It belongs to short-term trading strategies.

Overview
This strategy uses the CK channel to determine price trends and sets dynamic stop loss lines to make reverse operations when price reversal occurs. It belongs to short-term trading strategies.
Strategy Principle
The strategy uses the CK channel to determine price trends and support/resistance. It calculates the upper and lower channel lines. When the price breaks through the channel lines, trading signals are generated. In addition, the strategy also tracks the movement of the channel lines and takes reverse positions when the channel lines reverse, which belongs to reversal trading strategies.
Specifically, the strategy calculates the upper and lower channel lines based on the highest and lowest prices. If the upper channel line starts to fall and the lower channel line starts to rise, it is determined as a price reversal to go short. On the contrary, if the lower channel line starts to fall and the upper channel line starts to rise, it is determined as a price reversal to go long.
Advantages of the Strategy
- Use double channels to determine price reversal points for accurate reverse operations
- Adopt dynamic stop loss to control risks and realize timely stop loss
- The strategy logic is simple and clear, easy to understand and implement
Risks of the Strategy
- When market prices fluctuate violently, the stop loss line may be broken, leading to greater losses
- More frequent trading can increase transaction costs
- Need to choose appropriate parameters to control the stop loss line, avoid too loose or too tight
Optimization of the Strategy
- Optimize stop loss line parameters to make it more reasonable and effective
- Incorporate trend indicators to judge the reliability of reversal signals, avoid reverse operations during the trend
- Increase automatic trading and automatic stop loss modules to reduce transaction costs
Summary
The overall idea of the strategy is clear and easy to understand. It uses double channels to determine price reversals and take reverse operations. And it sets dynamic stop loss to control risks. It belongs to typical short-term trading strategies. The strategy effect can be further optimized, mainly by adjusting the stop loss parameters and assisting other technical indicators to determine entry and exit timing.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 9 | hiP |
| v_input_2 | true | hix |
| v_input_3 | 7 | hiQ |
| v_input_4 | 9 | loP |
| v_input_5 | true | lox |
| v_input_6 | 5 | loQ |
| v_input_7 | false | Reverse operation: buy/sell |
| v_input_8 | true | Sig |
| v_input_9 | true | Bgtrend |
| v_input_10 | 2021 | Year |
| v_input_11 | 9 | Moon |
| v_input_12 | true | day |
| v_input_13 | 2032 | Year |
| v_input_14 | true | Moon |
| v_input_15 | true | day |
| v_input_16 | My Long Msg | Long Alert Msg |
| v_input_17 | My Short Msg | Short Alert Msg |
Source Pine Script
/*backtest
start: 2023-10-27 00:00:00
end: 2023-11-26 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
//
//study(title="Chande Kroll Stop", shorttitle="CK Stop", overlay=true)
strategy(title="Chande Kroll Stop", shorttitle="Chande Kroll StopBacktest", overlay=true, initial_capital=100000, calc_on_every_tick=true,default_qty_type=strategy.percent_of_equity, default_qty_value=10)
br_red = #e91e63,Red = #f41818,n_green = #91dc16,dk_green = #004d40,lt_green = #16dc78,lt_blue = #0dbdd8,dk_blue = #0a3577,Blue = #034fed,br_orange = #f57c00,dk_orange = #e65100,dk_gray = #434651,dk_pink = #7c1df0,lt_pink = #e743f5,Purple = #5b32f3,lt_purple = #6b5797
hiP = input(9, "",inline="h")
hix = input(1,"" ,inline="h", step=0.1)
hiQ = input(7,"" ,inline="h")
loP = input(9,"" ,inline="h1")
lox = input(1,"" ,inline="h1", step=0.1)
loQ = input(5,"" ,inline="h1")
Xr=input(false,"Reverse operation: buy/sell",inline="T"),
first_high_stop = highest(high, hiP) - hix * atr(hiP)
first_low_stop = lowest(high, loP) + lox * atr(loP)
stop_short = highest(first_high_stop, hiQ)
stop_long = lowest(first_low_stop, loQ)
cklow = stop_short
ckhigh = stop_long
Xdn = cklow < cklow[1] and ckhigh < ckhigh[1]
Xup = cklow > cklow[1] and ckhigh > ckhigh[1]
longcol = Xup ? lt_green : Xdn ? br_red : #2a2e39
shortcol = Xup? lt_green : Xdn ? br_red : #2a2e39
plot(stop_long, color=longcol)
plot(stop_short, color=shortcol)
plotshape(Xup and not Xup[1] , title="CK Stop Buy", text='CK', style=shape.triangleup, size=size.tiny, location=location.belowbar, color=lt_green, textcolor=lt_green,display=display.none)
plotshape(Xdn and not Xdn[1], title="CK Stop Sell", text='CK', style=shape.triangledown, size=size.tiny, location=location.abovebar, color=br_red, textcolor=br_red,display=display.none)
// , default_qty_type=strategy.percent_of_equity, default_qty_value=10, calc_on_every_tick=true)
tl=input(true,"Sig",inline="T"), sbg=input(true,"Bgtrend",inline="T"), vbuild="FIREHORSE XRPUSDT"
Xp = 0.0, Xp:=Xdn? -1 : Xup? 1 : Xp[1], Xdf = Xr? Xup and Xp[1] == -1 : Xdn and Xp[1] == 1 ,Xuf = Xr? Xdn and Xp[1] == 1: Xup and Xp[1] == -1
FY=input(2021,"year",inline="btf"),FM=input(9,"month",inline="btf"),FD=input(01,"day",inline="btf"),
TY = input(2032,"year",inline="to"),TM=input(01,"month",inline="to"),TDy=input(01,"day",inline="to"),
testTF = time>=timestamp(FY,FM,FD,00,00) and time <= timestamp(TY,TM,TDy,23,59)? true:false
plotchar(tl? Xuf:na,vbuild+" Shengmen","△",location.bottom, #14e540,10,0," " ,#14e540,1,size.tiny)// ︽ ︾
plotchar(tl? Xdf:na,vbuild+" Injury door","▽",location.top, #9b0842,10,0," ", #9b0842,1,size.tiny)
bgcolor(sbg ? Xp==1 ? #0d47a1 :na: na, transp=90),
alertcondition(Xuf,vbuild+ "Buy", "Long ? \n"+vbuild), alertcondition(Xdf, vbuild+ " Sell","Short ?\n"+vbuild)
if Xuf
alert("Long " + tostring(close)+"\nLong "+input("My Long Msg","Long Alert Msg")+vbuild, alert.freq_once_per_bar)
if Xdf
alert("Short " + tostring(close)+"\nShort"+input("My Short Msg","Short Alert Msg")+vbuild, alert.freq_once_per_bar)
if testTF
strategy.entry("Long ", strategy.long, comment=" Long ",when=Xuf), strategy.entry("Short", strategy.short, comment=" Short",when=Xdf )
Published by ChaoZhang on the FMZ strategy square · last modified 2023-11-27. 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/CK-Momentum-Reversal-Stop-Loss-Strategy.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 Trading Strategy Combining Dynamic Trend Reversal and Stochastic IndicatorPine Script · Mean reversion · 1d
- Advanced Fibonacci Retracement Trend Following and Reversal Trading StrategyPine Script · Mean reversion · 3h
- Advanced Momentum EMA Trend Following with RSI Overbought Oversold Trading StrategyPine Script · Mean reversion · 1d
- Dynamic MACD and Ichimoku Cloud Trading StrategyPine Script · Mean reversion · 1h
- Multi Level Support Resistance Weekly Mean Reversion Trading StrategyPine Script · Mean reversion · 1d
- Oma and Apollo Dual Rail Trading StrategyPine Script · Mean reversion · 5m