Strategy vault / Mean reversion
123 Reversal Moving Average Convergence Divergence Combination Strategy
This strategy combines the 123 reversal trading strategy proposed by Ulf Jensen in his book with the Moving Average Convergence Divergence Oscillator (KST) proposed by Martin Pring to build a quantitative strategy…

Overview
This strategy combines the 123 reversal trading strategy proposed by Ulf Jensen in his book with the Moving Average Convergence Divergence Oscillator (KST) proposed by Martin Pring to build a quantitative strategy that generates trading signals by utilizing reversal patterns and trend oscillation indicators.
Strategy Principle
123 Reversal Formation Mechanism
The core logic of this part of the strategy is to monitor whether the closing price of the stock has reversed in the past 2 days, specifically:
If the closing prices in the past 2 days are in a downward trend, that is, the previous day's closing price is higher than the one before; and today's closing price rebounds upward from the previous day, which is higher than the previous day's closing price, it can be judged as a bottom reversal and a buy signal is generated.
On the contrary, if the closing prices in the past 2 days are in an upward trend, that is, the previous day's closing price is lower than the one before; and today's closing price falls from the previous day, which is lower than the previous day's closing price, it can be judged as a top reversal and a sell signal is generated.
This part of the strategy also combines the Stochastic indicator to determine whether it is overbought or oversold to filter out non-reversal trading signals.
KST Indicator Principle
In the KST indicator, ROC represents the rate of change in price, calculating the ROCs of 6 days, 10 days, 15 days and 20 days respectively, and performing weighted summation after different parameter moving average smoothing to construct the KST indicator.
When the fast line crosses above the slow line, it is judged as bullish; when the fast line crosses below the slow line, it is judged as bearish. Here, the fast line is the original KST value, and the slow line is the moving average of KST.
This strategy uses KST>0 to judge bullish and KST<0 to judge bearish.
Signal Merge
The Judgment signals of the 123 reversal strategy and the KST indicator are combined:
- If both signals are the same, a trading signal is generated in that direction
- If the two signals are different, no trading occurs
It can be seen that this strategy comprehensively uses two different types of technical indicators, the reversal pattern and indicator judgment, and combines their signal strengths to design a more advanced quantitative trading strategy.
Advantages of the Strategy
- The reversal part can effectively identify turning points, and the indicator part can track trends, complementing each other
- Filtering with dual indicators can improve signal quality and reduce false signals
- Flexible adjustment of KST parameters for optimization for stocks of different cycles
- Can adapt to high volatility stocks, can also be used for relatively stable stocks
Risks of the Strategy
- Risk of reversal failure, reversal signal may also be false breakout
- Some opportunities may be missed after signal merge
- Improper KST parameters may greatly interfere with results
- When stock price fluctuates sharply, KST lags, inconsistent signals may appear
Methods like parameter adjustment, optimization of reversal logic, introduction of stop loss mechanism can be used to control risks.
Optimization Direction
- Optimize Stochastic Parameters
- Optimize length parameters of KST line
- Add trading volume or volatility index filter
- Add trend judgment to avoid trading against trend
- Introduce stop loss mechanism
Conclusion
This strategy integrates multiple different types of technical indicators. Through dual confirmation and combination optimization, it scientifically designs a relatively strong quantitative trading strategy, and it is a model of strategy combination. Its performance in live trading is yet to be further verified, but from the theoretical conceptualization perspective, it comprehensively considers multiple scenarios, solves the limitations of single indicators, and is worth further research and application.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | true | ---- 123 Reversal ---- |
| v_input_2 | 14 | Length |
| v_input_3 | true | KSmoothing |
| v_input_4 | 3 | DLength |
| v_input_5 | 50 | Level |
| v_input_6 | false | Trade reverse |
Source Pine Script
/*backtest
start: 2023-10-22 00:00:00
end: 2023-11-21 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 23/03/2021
// This is combo strategies for get a cumulative signal.
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
// The strategy sells at market, if close price is lower than the previous close price
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// This indicator really is the KST indicator presented by Martin Pring.
// the KST indicator is a weighted summed rate of change oscillator that
// is designed to identify meaningful turns. Various smoothed rate of change
// indicators can be combined to form different measurements of cycles.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
vFast = sma(stoch(close, high, low, Length), KSmoothing)
vSlow = sma(vFast, DLength)
pos = 0.0
pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0)))
pos
MROC() =>
pos = 0.0
xROC6 = sma(roc(close, 6), 10)
xROC10 = sma(roc(close, 10), 10)
xROC15 = sma(roc(close, 15), 9)
xROC20 = sma(roc(close, 20), 15)
nRes = xROC6 + (2 * xROC10) + (3 * xROC15) + (4 * xROC20)
pos := iff(nRes > 0, 1,
iff(nRes < 0, -1, nz(pos[1], 0)))
pos
strategy(title="Combo Backtest 123 Reversal & MovROC (KST indicator)", shorttitle="Combo", overlay = true)
line1 = input(true, "---- 123 Reversal ----")
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posMROC = MROC()
pos = iff(posReversal123 == 1 and posMROC == 1 , 1,
iff(posReversal123 == -1 and posMROC == -1, -1, 0))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1 , 1, pos))
if (possig == 1 )
strategy.entry("Long", strategy.long)
if (possig == -1 )
strategy.entry("Short", strategy.short)
if (possig == 0)
strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )Published by ChaoZhang on the FMZ strategy square · last modified 2023-11-22. 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/123-Reversal-Moving-Average-Convergence-Divergence-Combination-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 15 Minute Chart Trading Signal StrategyPine Script · Mean reversion · 3h
- Bollinger Bands Stochastic RSI Extreme Strategy BBSR Extreme StrategyPine Script · Mean reversion · 1h
- BuySell Strategy depends on AOStochRSIATRPine Script · Mean reversion · 30m
- Byron Serpent Cloud Quant StrategyPine Script · Mean reversion · 1h
- Dual Momentum Trend Reversal Strategy Based on RSI and Stochastic RSIPine Script · Mean reversion · 1h