Strategy vault / Trend following
CM Multiple EMA Crossover Strategy
This strategy combines 8-day, 13-day, 21-day and 55-day EMAs and generates long and short signals when crossover occurs between them, aiming to capture mid-long term trends.
Overview
This strategy combines 8-day, 13-day, 21-day and 55-day EMAs and generates long and short signals when crossover occurs between them, aiming to capture mid-long term trends.
Strategy Logic
Calculate 8-day, 13-day, 21-day and 55-day EMAs.
When 8-day, 13-day, 21-day EMAs all cross above 55-day EMA, long signal triggered.
When 8-day, 13-day, 21-day EMAs all cross below 55-day EMA, short signal triggered.
Go long on golden cross, go short on death cross.
Close position on reverse crossover.
Advantage Analysis
Multiple EMA combo effective in filtering false breakouts.
55-day EMA as anchor avoids being trapped.
Backtest shows steady annual returns over past 10 years.
Visual crossover, simple to operate, beginner friendly.
Risk Analysis
Fixed parameters may not fit all products and markets, independent optimization needed.
Ineffective in ranging markets, risks whipsaws and frequent stops.
No stop loss unable to limit single trade loss.
Trade frequency may be too high or low, parameter tweak needed.
10-year sample limited, need larger data to verify robustness.
Optimization Directions
Test EMA period combinations to find best match.
Add volume filter to avoid false breakouts.
Implement fixed or moving stop loss.
Optimize position sizing to lower risk per trade.
Trade both long and short sides.
Expand testing into more products and longer timeframe.
Summary
This strategy identifies mid-long term trends using EMA crosses in intuitive visual way. Strengths are visibility and simplicity. But parameters need more optimization and lacks risk control. More technical indicators should be introduced to filter signals and stops added to limit losses. Also requires large sample backtests across products and time to refine and verify, to become a robust trend following system.
Source Pine Script
/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 6h
basePeriod: 15m
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/
// © ColinMccann18
//@version=4
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// --------------------------------------------------------------RULES------------------------------------------------------------------------------
// - VISUALLY REPRESENTS THE CROSSING OF 8,13,21,55 EMA'S FROM KROWNS PROGRAM
strategy(title="CM EMA Trend Cross STRAT", shorttitle="CM EMA Strat", overlay=true)
ema8 = ema(close,8)
ema13 = ema(close, 13)
ema21 = ema(close, 21)
ema55 = ema(close, 55)
//PLOT
plot(ema8, title="EMA 1",linewidth=2, color=#00eeff)
plot(ema13, title="EMA 2",linewidth=2, color=#fff900)
plot(ema21, title="EMA 3",linewidth=2, color=#42ff0f)
plot(ema55, title="EMA 4",linewidth=2, color=#8b49ff)
//LOGIC---------------------------------------------------------------------------------------------------------------------------------
emacrossover = crossover(ema21, ema55) and ema8 and ema13 > ema55
emacrossunder = crossunder(ema21, ema55) and ema8 and ema13 < ema55
//Long----------------------------------------------------------------------------------------------------------------------------------
longCondition = emacrossover
closelongCondition = emacrossunder
strategy.entry("Long", strategy.long, qty=na, when=longCondition)
strategy.close("Close Long", when=closelongCondition)
//Short----------------------------------------------------------------------------------------------------------------------------------
shortCondition = emacrossunder
closeshortCondition = emacrossover
strategy.entry("Short", strategy.short,qty=na, when=shortCondition)
strategy.close("Close Short", when=closeshortCondition)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-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/CM-Multiple-EMA-Crossover-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
- Dynamic Dual EMA Trend Following StrategyPine Script · Trend following · 1d
- EMA 200 Crossover with Volume and Trend StrategyPine Script · Trend following · 1d
- EMA SMA Trend Following with Swing Trading Strategy Combined Volume Filter and Percentage Take Profit Stop Loss SystemPine Script · Trend following · 1d
- Fixed Range Volume Profile And Anchored VWAP Trend Identification Strategy With Dynamic Stop LossPine Script · Trend following · 1h
- Multi Exponential Moving Average Crossover Strategy with Volume Based ATR Dynamic Stop Loss OptimizationPine Script · Trend following · 2d
- Multi Factor Trend Price Action Strategy with Dynamic Risk Management SystemPine Script · Trend following · 2h