Strategy vault / Trend following
Trend Following Strategy Based on KST Indicator
Trend Following Strategy Using KST Indicator This article explains in detail a quantitative trend following strategy using the KST indicator. It generates trading signals by calculating the crossover between the KST…
Trend Following Strategy Using KST Indicator
This article explains in detail a quantitative trend following strategy using the KST indicator. It generates trading signals by calculating the crossover between the KST line and signal line.
I. Strategy Logic
The main steps for signal generation are:
Calculate values of multiple ROC indicators with different periods.
Apply moving averages to the ROC values separately and take the sum to derive the KST line.
Further smooth the KST line using moving average to get the signal line.
A buy signal is generated when the KST line crosses above the signal line, and vice versa for sell signals.
Appropriate position sizing can be selected.
By taking the sum of multiple ROC values, the KST line reflects both short-term and long-term price trends. Its crossover with the signal line can determine trend direction.
II. Advantages of the Strategy
The biggest advantage is the comprehensive indicator calculation, which incorporates trend information across timeframes.
Another advantage is the simple and intuitive indicator usage with a clear signal line.
Lastly, adjustable position sizing helps control overall risk exposure.
III. Potential Weaknesses
However, some issues exist:
Firstly, the indicator itself has some lag in reacting to price changes.
Secondly, reliance on just the KST makes it susceptible to reversals.
Also, extensive optimization is required to avoid overfitting.
IV. Summary
In summary, this article has explained a quantitative trend following strategy using KST crossover signals. It reflects price trends through the indicator for trade signals, but requires managing indicator lag and proper parameter tuning. Overall it provides a simple trend tracking approach.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_int_1 | 10 | ROC Length #1 |
| v_input_int_2 | 15 | ROC Length #2 |
| v_input_int_3 | 20 | ROC Length #3 |
| v_input_int_4 | 30 | ROC Length #4 |
| v_input_int_5 | 10 | SMA Length #1 |
| v_input_int_6 | 10 | SMA Length #2 |
| v_input_int_7 | 10 | SMA Length #3 |
| v_input_int_8 | 15 | SMA Length #4 |
| v_input_int_9 | 9 | Signal Line Length |
Source Pine Script
/*backtest
start: 2023-08-15 00:00:00
end: 2023-09-14 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
// strategy(title="KST Alert", shorttitle="KST Alert", format=format.price, precision=4)
roclen1 = input.int(10, minval=1, title = "ROC Length #1")
roclen2 = input.int(15, minval=1, title = "ROC Length #2")
roclen3 = input.int(20, minval=1, title = "ROC Length #3")
roclen4 = input.int(30, minval=1, title = "ROC Length #4")
smalen1 = input.int(10, minval=1, title = "SMA Length #1")
smalen2 = input.int(10, minval=1, title = "SMA Length #2")
smalen3 = input.int(10, minval=1, title = "SMA Length #3")
smalen4 = input.int(15, minval=1, title = "SMA Length #4")
siglen = input.int(9, minval=1, title = "Signal Line Length")
smaroc(roclen, smalen) => ta.sma(ta.roc(close, roclen), smalen)
kst = smaroc(roclen1, smalen1) + 2 * smaroc(roclen2, smalen2) + 3 * smaroc(roclen3, smalen3) + 4 * smaroc(roclen4, smalen4)
sig = ta.sma(kst, siglen)
plot(kst, color=#009688, title="KST")
plot(sig, color=#F44336, title="Signal")
hline(0, title="Zero", color = #787B86)
eL1=ta.crossover(kst,sig)
eS1=ta.crossunder(kst,sig)
ch = 0
t = year(time('D'))
ch := ta.change(t) != 0 ? 1 : 0
T1 = time(timeframe.period, "0915-1520")
session_open = na(t) ? false : true
newDay = ta.change(time("15m")) != 0
strategy.entry("Long1", strategy.long, when = eL1)
strategy.entry("Short1", strategy.short, when = eS1)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-15. 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/Trend-Following-Strategy-Based-on-KST-Indicator.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
- ADX MA and EMA Long Only Trend Tracking StrategyPine Script · Trend following · 1d
- ATR and Moving Average Crossover Hybrid StrategyPine Script · Trend following · 1h
- Adaptive FVG Detection and MA Trend Trading Strategy with Dynamic ResistancePine Script · Trend following · 1d
- Adaptive Risk Management Strategy Based on Dynamic ATR and Moving Average CrossoverPine Script · Trend following · 2h
- Adaptive Trading Strategy Based on Stochastic RSI Dual Line CrossoverPine Script · Trend following · 4h
- Adaptive Volatility Based Trend Following Short Strategy with Time Delay and Stop Loss ProtectionPine Script · Trend following · 2m