Strategy vault / Trend following
Dual Moving Average Crossover Combined with RSI Indicator Quantitative Trading Strategy
This strategy combines dual moving average crossover and RSI indicator to identify trend direction and overbought/oversold situations. It goes long when the buying conditions are met and closes positions when the…

Overview
This strategy combines dual moving average crossover and RSI indicator to identify trend direction and overbought/oversold situations. It goes long when the buying conditions are met and closes positions when the selling conditions are triggered. The goal is to use moving average crossover to determine trend direction while utilizing RSI indicator to avoid wrongly buying at tops and selling at bottoms, thus generating better profits.
Strategy Logic
When the fast 9-period moving average crosses above the slow 50-period moving average, it signals an uptrend in shorter timeframe overlapping with an uptrend in longer timeframe, which is a typical bullish signal. Meanwhile, if RSI is greater than the previous period by 5 points and less than 70, it means the asset is approaching but not yet in the overbought territory, making it a good timing to go long.
When the fast 9-period moving average crosses below the slow 50-period moving average, it signals the beginning of a bearish market and existing long positions should be closed.
Advantage Analysis
- Dual moving averages help determine overall market direction and avoid false breakout
- RSI indicator prevents wrong moves at turning points
- Flexibility in adjusting moving average periods to suit different symbols and timeframes
- Controllable stop loss strategy
Risk Analysis
- Crossover signal may lag and cause some losses
- Improper RSI parameter setting may miss best entry timing
- Need to watch trading volume to see if it supports price move
- Black swan events require manual intervention
Optimization Directions
- Optimize RSI parameters for best results
- Incorporate trading volume to avoid false signals
- Test optimal moving average periods based on symbol and timeframe
- Loosen stop loss to avoid being stopped out early
Summary
This strategy utilizes dual moving average crossover to determine direction and RSI to avoid chasing tops and bottoms. It can effectively ride medium- to long-term trends for steady profits. But the lagging nature of crossover signals and tuning of RSI parameters should be watched out for. Also need to correlate price with volume. With continuous testing and optimization, this strategy shows promise for even better results.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | true | Show Date Range |
| v_input_2 | 14 | length |
Source Pine Script
/*backtest
start: 2022-11-14 00:00:00
end: 2023-11-20 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © joshuajcoop01
//@version=5
strategy("Bitpanda Coinrule Template",
overlay=true,
initial_capital=1000,
process_orders_on_close=true,
default_qty_type=strategy.percent_of_equity,
default_qty_value=30,
commission_type=strategy.commission.percent,
commission_value=0.1)
showDate = input(defval=true, title='Show Date Range')
timePeriod = time >= timestamp(syminfo.timezone, 2020, 1, 1, 0, 0)
notInTrade = strategy.position_size <= 0
// RSI
length = input(14)
vrsi = ta.rsi(close, length)
// Moving Averages for Buy Condition
buyFastEMA = ta.ema(close, 9)
buySlowEMA = ta.ema(close, 50)
buyCondition1 = ta.crossover(buyFastEMA, buySlowEMA)
increase = 5
if ((vrsi > vrsi[1]+increase) and buyCondition1 and vrsi < 70 and timePeriod)
strategy.entry("Long", strategy.long)
// Moving Averages for Sell Condition
sellFastEMA = ta.ema(close, 9)
sellSlowEMA = ta.ema(close, 50)
plot(request.security(syminfo.tickerid, "60", sellFastEMA), color = color.blue)
plot(request.security(syminfo.tickerid, "60", sellSlowEMA), color = color.green)
condition = ta.crossover(sellSlowEMA, sellFastEMA)
//sellCondition1 = request.security(syminfo.tickerid, "60", condition)
strategy.close('Long', when = condition and timePeriod)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-11-21. 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/Dual-Moving-Average-Crossover-Combined-with-RSI-Indicator-Quantitative-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
- Adaptive ATR and RSI Trend Following Strategy with Trailing Stop LossPine Script · Trend following · 1h
- Advanced Multi Indicator Multi Dimensional Trend Cross Quantitative StrategyPine Script · Trend following · 3h
- Bollinger Bands and RSI Trend Following StrategyPine Script · Trend following · 1h
- Dual ATR Channel Trend Following StrategyPine Script · Trend following · 15m
- Dual EMA Crossover with RSI Trend Confirmation StrategyPine Script · Trend following · 3h
- Dual Mode Adaptive Trend Trading Strategy EMA Crossover with ATR Volatility Based Risk Management SystemPine Script · Trend following · 1d