Momentum Rectangle Channel Dual Moving Average Trading Strategy
This strategy is based on momentum indicators of Rectangle Channel and Dual Moving Average, which implements a relatively complete stock trading system. The strategy first uses fast EMA and slow EMA to construct dual…

Overview
This strategy is based on momentum indicators of Rectangle Channel and Dual Moving Average, which implements a relatively complete stock trading system. The strategy first uses fast EMA and slow EMA to construct dual moving average trading signals. Then, combined with the Rectangle Channel indicator, it further verifies the trading signals to achieve more accurate entry. In addition, the strategy also uses the SAR indicator to assist in judging the trend direction.
Strategy Principle
Calculate the moving averages of fast EMA with period 5 days and slow EMA with period 50 days. Fast EMA reflects recent price changes and slow EMA reflects long term trends.
Convert EMA to TEMA (Triple Exponential Moving Average), using TEMA's weighted calculation method to improve the sensitivity of the curve and capture price changes faster.
When fast TEMA crosses above slow TEMA, a buy signal is generated; when fast TEMA crosses below slow TEMA, a sell signal is generated. The principle of dual moving average crossover is widely used in quantitative trading.
Calculate the price channel width to form channel areas. Trading signals are only considered when prices break through the channel. This can filter false signals and verify the real start of a trend.
SAR indicator determines the overall trend direction, combined with the dual moving average trading signals, can avoid unnecessary reverse operations.
Advantages of the Strategy
The combination of dual moving average crossover and channel breakthrough can effectively identify the beginning of a trend, filter noise, and make buy and sell signals more accurate and reliable.
The TEMA curve is more sensitive than the EMA curve and can capture price changes faster.
The combination of multiple indicators can form a verification mechanism between indicators to avoid the limitations of a single indicator and make the strategy more comprehensive and robust.
The strategy parameters are flexible, EMA cycles, channel widths, etc. can be adjusted and optimized according to market conditions for strong adaptability.
Risks of the Strategy
There is a probability of violent fluctuations in stock prices in the short term, which can easily trigger a stop loss.
Sudden events may cause price gaps that cannot be traded at expected prices.
Dual moving average crossovers cannot completely avoid false signals, there is still a certain misjudgment rate.
Improper parameter settings can lead to excessively frequent or lagging trading signals.
Optimization Directions
More indicators such as KD and MACD can be combined for verification to make the strategy more comprehensive and reliable.
Dynamic cycles can be set to adjust the parameters of EMA and Channel according to the degree of market volatility, making the strategy more flexible.
Machine learning models can be established to train a large amount of historical data to automatically optimize parameter settings and reduce manual intervention.
Text analysis and news sentiment judgment can be combined to avoid unnecessary trading when major news is released.
Summary
This strategy forms trading signals through fast-slow TEMA moving average crossover, and then verifies them with price channel and SAR indicator, which can effectively identify the beginning of stock price trends and make buy and sell operations at reasonable positions. The combination of multiple indicators to verify each other can improve the reliability of signals and is a relatively robust and efficient stock trading strategy. By continuously optimizing parameter settings, adding new verification indicators, etc., the effect of the strategy can be further improved.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 5 | Fast TEMA Period |
| v_input_2 | 50 | Slow TEMA Periods |
| v_input_3 | true | From Month |
| v_input_4 | 4 | From Day |
| v_input_5 | 2010 | From Year |
| v_input_6 | true | To Month |
| v_input_7 | true | To Day |
| v_input_8 | 9999 | To Year |
Source Pine Script
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy("TEMA_System_SAR", overlay=true)
//Collect inputs parameters
fastEmaPeriod = input(5, minval=1, title="Fast TEMA Period")
slowEmaPeriod = input(50, minval=1, title="Slow TEMA Periods")
// === INPUT BACKTEST RANGE ===
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay = input(defval = 4, title = "From Day", minval = 1, maxval = 31)
FromYear = input(defval = 2010, title = "From Year", minval = 2000)
ToMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToYear = input(defval = 9999, title = "To Year", minval = 2000)
// === FUNCTION EXAMPLE ===
start = timestamp(FromYear, FromMonth, FromDay, 09, 15) // backtest start window
finish = timestamp(ToYear, ToMonth, ToDay, 15, 30) // backtest finish window
window() => true
fastEma = ema(close, fastEmaPeriod)
slowEma = ema(close, slowEmaPeriod)
//convert EMA into TEMA
ema1 = ema(close, fastEmaPeriod)
ema2 = ema(ema1, fastEmaPeriod)
ema3 = ema(ema2, fastEmaPeriod)
fastTEMA = 3 * (ema1 - ema2) + ema3
// convert EMA into TEMA
ema4 = ema(close, fastEmaPeriod)
ema5 = ema(ema1, fastEmaPeriod)
ema6 = ema(ema2, fastEmaPeriod)
slowTEMA = 3 * (ema4 - ema5) + ema6
buy = close > fastTEMA
sell = close < fastTEMA
plot(fastTEMA, title = 'fast TEMA', linewidth=2, color=white)
plot(slowTEMA, title = 'slow TEMA', linewidth=2, color=yellow)
strategy.entry("long",strategy.long, when = window() and buy)
strategy.entry("short", strategy.short, when = window() and sell)Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-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/Momentum-Rectangle-Channel-Dual-Moving-Average-Trading-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
- Advanced Multi Indicator Trend Following and Momentum Quantitative Trading StrategyPine Script · Momentum · 1h
- Momentum Trend Following Dual Indicator MACD and Parabolic SAR Combination StrategyPine Script · Momentum · 1d
- Vishal Adaptive Multi Indicator Trading StrategyPine Script · Momentum · 2d
- Multi Indicator Comprehensive Analysis Quantitative Trading Strategy Trend Momentum and Volatility Collaborative Prediction ModelPine Script · Momentum · 3m
- Stochastic RSI Momentum Oscillation Trading StrategyPine Script · Momentum · 1h
- Multi Timeframe Moving Average Momentum Trading StrategyPine Script · Momentum · 1h