0bps

Strategy vault / Mean reversion

Combo Strategy with Multiple Indicators

This strategy combines multiple technical indicators to generate more precise and reliable trading signals. It consists of two parts: the first part uses 123 reversal strategy, and the second part uses TEMA…

Author
ChaoZhang
Complexity
Intermediate · 72 lines
Parameters
8
Backtest bar
45m · intraday
Tested on
BTC/USDT · futures

Overview

This strategy combines multiple technical indicators to generate more precise and reliable trading signals. It consists of two parts: the first part uses 123 reversal strategy, and the second part uses TEMA indicator. The trading signals generated by both are combined to filter out wrong signals and improve signal quality.

Strategy Logic

The first part uses 123 reversal strategy. It is based on the stochastic indicator. When the closing price shows reversal for two consecutive days (e.g. turning from rise to fall), and the stochastic indicator shows overbought or oversold signal, it generates buy or sell signals.

Specifically, when the closing price is higher than the previous day's and the stochastic slow line is below 50, it generates a buy signal. When the closing price is lower than the previous day's and the stochastic fast line is above 50, it generates a sell signal.

The second part uses the TEMA indicator. TEMA stands for Triple Exponential Moving Average, and is calculated as:

TEMA = 3EMA(CLOSE, N) - 3EMA(EMA(CLOSE, N), N) + EMA(EMA(EMA(CLOSE, N), N), N)

Where N is the parameter length. If closing price is above TEMA value, it generates a buy signal. If closing price is below TEMA value, it generates a sell signal.

Finally, the signals from the two indicators are combined. Only when both indicators generate consistent signals (both buy or both sell), actual trading signals are generated.

Advantages

  • Combining multiple indicators helps filter out some wrong signals and improves signal quality.
  • 123 reversal strategy avoids chasing high prices and panic selling by reacting to actual price reversals.
  • TEMA's multiple smoothing reduces noise and generates more reliable signals.
  • Combining two different types of indicators largely ensures the reliability of trading signals.

Risks and Improvement

  • Reversal strategies have inherent risks of missing major upward trends in a bull market. Fine tuning parameters could reduce missing out probability.
  • TEMA as a trend following indicator can also generate wrong signals sometimes. Adjusting TEMA parameters could optimize indicator sensitivity.
  • If parameters are improperly set, both indicators could generate too few signals. Parameters need to be tuned for proper trade frequency.
  • Adding filters to disable strategies in certain market environments could help control risks.

Summary

This strategy improves signal quality through reasonable combination of multiple indicators, making it a very effective quantitative trading strategy. But risk management is still needed, like fine tuning parameters or adding other components for optimization, so that the strategy can keep stable performance across different markets.

Parameters

NameDefaultWhat it controls
v_input_1true---- 123 Reversal ----
v_input_214Length
v_input_3trueKSmoothing
v_input_43DLength
v_input_550Level
v_input_6true---- TEMA1 ----
v_input_726LengthTEMA
v_input_8falseTrade reverse

Source Pine Script

/*backtest
start: 2023-09-29 00:00:00
end: 2023-10-06 00:00:00
period: 45m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 24/11/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 study plots the TEMA1 indicator. TEMA1 ia s triple MA (Moving Average),
// and is calculated as 3*MA - (3*MA(MA)) + (MA(MA(MA)))
//
// 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


TEMA(Length) =>
    pos = 0.0
    xPrice = close
    xEMA1 = ema(xPrice, Length)
    xEMA2 = ema(xEMA1, Length)
    xEMA3 = ema(xEMA2, Length)
    nRes = 3 * xEMA1 - 3 * xEMA2 + xEMA3
    pos := iff(close > nRes, 1,
             iff(close < nRes, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & TEMA1", 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)
//-------------------------
line2 = input(true, "---- TEMA1 ----")
LengthTEMA = input(26, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posT3A = TEMA(LengthTEMA)
pos = iff(posReversal123 == 1 and posT3A == 1 , 1,
	   iff(posReversal123 == -1 and posT3A == -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-10-07. 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.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Combo-Strategy-with-Multiple-Indicators.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. 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

esc

Try , , or .

↑↓ move↵ open