0bps

Strategy vault / Mean reversion

Multi Period EMA Trend Following with RSI Overbought Oversold Dynamic Optimization Strategy

This strategy is a trend-following trading system based on multiple technical indicators, combining EMA trends, RSI overbought/oversold conditions, and ATR volatility indicators to improve trading win rates and…

Author
ChaoZhang
Complexity
Starter · 59 lines
Parameters
0
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

Overview

This strategy is a trend-following trading system based on multiple technical indicators, combining EMA trends, RSI overbought/oversold conditions, and ATR volatility indicators to improve trading win rates and returns through multi-dimensional market analysis. The core logic uses short-term and long-term EMA crossovers to confirm trend direction, while utilizing RSI indicators to filter false breakouts and ATR to dynamically adjust holding periods for precise trend capture.

Strategy Principles

The strategy employs 20-day and 50-day EMAs as the primary basis for trend determination. An uptrend is confirmed when the short-term EMA crosses above the long-term EMA, and vice versa. Building on trend confirmation, the RSI indicator is introduced for overbought/oversold judgment, triggering long signals when RSI falls below 30 in oversold territory during uptrends, and short signals when RSI rises above 70 in overbought territory during downtrends. The ATR indicator measures market volatility, executing trades only when ATR exceeds the set threshold to avoid trading in low-volatility environments.

Strategy Advantages

  1. Multiple technical indicators combination provides more reliable trading signals, effectively reducing false breakout risks
  2. Dynamic holding period adjustment through ATR enables adaptation to different market environments
  3. RSI incorporation helps avoid entering during excessive chase-ups or sell-offs
  4. Fixed holding period design aids risk control and prevents over-holding
  5. Clear strategy logic with adjustable parameters facilitates optimization for different market conditions

Strategy Risks

  1. May generate frequent false signals in ranging markets, increasing transaction costs
  2. Fixed holding periods might lead to early exits in strong trends, missing profit opportunities
  3. Multiple indicator usage can result in lagging signals, affecting entry timing
  4. RSI overbought/oversold judgments may not be timely enough in fast-moving markets
  5. ATR threshold settings require constant adjustment based on market conditions, making parameter optimization challenging

Strategy Optimization Directions

  1. Introduce adaptive parameter mechanisms to dynamically adjust EMA periods and RSI thresholds based on market volatility
  2. Add volume indicators as auxiliary confirmation to improve signal reliability
  3. Develop dynamic holding period mechanisms to automatically adjust based on trend strength
  4. Incorporate additional market sentiment indicators like MACD or Bollinger Bands to enhance strategy adaptability
  5. Optimize stop-loss and take-profit mechanisms using trailing stops to improve profitability

Summary

This strategy constructs a relatively complete trading system through comprehensive analysis of EMA trends, RSI overbought/oversold conditions, and ATR volatility. Its core advantage lies in cross-validation of multiple indicators, effectively reducing the impact of false signals. Through parameter optimization and risk control mechanism improvements, the strategy still has significant optimization potential. Traders are advised to adjust parameters according to specific market environments and strictly implement risk control measures when using in live trading.

Source Pine Script

/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-04 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("High Win Rate BTC Strategy", overlay=true)

// Parameter Settings
emaShortLength = input(20, title="Short EMA Length")
emaLongLength = input(50, title="Long EMA Length")
rsiLength = input(14, title="RSI Length")
rsiOverbought = input(70, title="RSI Overbought Level")
rsiOversold = input(30, title="RSI Oversold Level")
atrLength = input(14, title="ATR Length")
atrThreshold = input(1.0, title="ATR Threshold")
holdBars = input(5, title="Hold Bars")

// Calculate indicator
emaShort = ta.ema(close, emaShortLength)
emaLong = ta.ema(close, emaLongLength)
rsi = ta.rsi(close, rsiLength)
atr = ta.atr(atrLength)

// Trend Confirmation
uptrend = emaShort > emaLong
downtrend = emaShort < emaLong

// Entry Conditions
longCondition = uptrend and close > emaShort and rsi < rsiOverbought and atr > atrThreshold
shortCondition = downtrend and close < emaShort and rsi > rsiOversold and atr > atrThreshold

// Exit Conditions
var int holdCount = 0
if (strategy.position_size > 0 or strategy.position_size < 0)
    holdCount := holdCount + 1
else
    holdCount := 0

exitCondition = holdCount >= holdBars

// Execute Trade
if (longCondition)
    strategy.entry("Long", strategy.long)
if (shortCondition)
    strategy.entry("Short", strategy.short)

if (exitCondition)
    strategy.close_all()

// Draw Indicator
plot(emaShort, color=color.blue, title="Short EMA")
plot(emaLong, color=color.red, title="Long EMA")
hline(rsiOverbought, "RSI Overbought", color=color.red)
hline(rsiOversold, "RSI Oversold", color=color.green)
plot(rsi, color=color.purple, title="RSI")

Published by ChaoZhang on the FMZ strategy square · last modified 2025-01-06. 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/Multi-Period-EMA-Trend-Following-with-RSI-Overbought-Oversold-Dynamic-Optimization-Strategy.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