Strategy vault / Machine learning
Multiple EMA Buy Strategy
This is a buy-only strategy based on price action and short-term trend. It uses multiple exponential moving averages (EMA) as technical indicators for entry and exit.

Overview
This is a buy-only strategy based on price action and short-term trend. It uses multiple exponential moving averages (EMA) as technical indicators for entry and exit.
Strategy Logic
The strategy employs six EMAs - 5-day, 10-day, 20-day, 50-day, 100-day and 200-day EMA. The buy signal is triggered when:
- 5-day EMA crosses above 10-day EMA
- 10-day EMA crosses above 20-day EMA
- 20-day EMA crosses above 50-day EMA
- 50-day EMA crosses above 100-day EMA
- 100-day EMA crosses above 200-day EMA
- Close price crosses above 5-day EMA
When all six conditions are met, a long position is initiated.
The exit signal is when close price crosses below 200-day EMA.
Advantage Analysis
The advantages of this strategy include:
- Using multiple EMAs as filters to identify medium-short term trends effectively
- Strict crossover criteria on multiple EMAs help avoid false breakouts
- Incorporating close price avoids false breakout risks
- Buy-only, avoids shorting risks
- Conservative exit mechanism favorable for profit taking
Risk Analysis
There are also some risks:
- Low probability of consecutive EMA crossovers, tends to miss opportunities
- Buy-only, cannot profit from drops
- Prone to being trapped in ranging markets
- Exits prematurely, giving up some profits
- Static parameter settings not adaptive across products and markets
Solutions:
- Reduce number of EMAs based on market conditions
- Consider incorporating CCI etc. to introduce shorting opportunities
- Set trailing stop loss or manual oversight
- Adjust parameters based on trending products
- Manual oversight advised to adjust parameters
Enhancement Opportunities
Some ways to enhance the strategy:
- Incorporate volume to avoid false breakouts
- Utilize volatility measures to optimize parameters
- Introduce machine learning models to dynamically optimize parameters
- Add breakout validation mechanisms
- Incorporate deep learning models for trend forecast
- Introduce stop loss and take profit
Conclusion
In summary, this is a medium-short term trend following strategy based on price technical indicators. It identifies trends using multiple EMA filters and incorporates close price to avoid false breakouts. The logic is simple and easy to understand. The disadvantages are fewer opportunities and prone to being trapped. It is suggested to be used as a supplementary tool combined with manual oversight. Enhancements can be made in aspects like volume, parameter optimization and machine learning to make the strategy more robust.
Source Pine Script
/*backtest
start: 2023-02-13 00:00:00
end: 2024-02-19 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Multiple EMA Buy Strategy with Price Condition", overlay=true)
// Calculate EMAs
ema5 = ta.ema(close, 5)
ema10 = ta.ema(close, 10)
ema20 = ta.ema(close, 20)
ema50 = ta.ema(close, 50)
ema100 = ta.ema(close, 100)
ema200 = ta.ema(close, 200)
// Plot EMAs
plot(ema5, color=color.blue, title="EMA 5")
plot(ema10, color=color.green, title="EMA 10")
plot(ema20, color=color.red, title="EMA 20")
plot(ema50, color=color.purple, title="EMA 50")
plot(ema100, color=color.orange, title="EMA 100")
plot(ema200, color=color.yellow, title="EMA 200")
// Entry conditions
buy_condition = ema5 > ema10 and ema10 > ema20 and ema20 > ema50 and ema50 > ema100 and ema100 > ema200 and close > ema5
// Exit conditions
exit_condition = close < ema200
// Strategy entry and exit conditions
strategy.entry("Buy", strategy.long, when = buy_condition)
strategy.close("Buy", when = exit_condition)Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-20. 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/Multiple-EMA-Buy-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
- Triple Moving Average Combined with MACD Quantitative StrategyPine Script · Machine learning · 1d
- kNN based Trend Following StrategyPine Script · Machine learning · 1h
- High Low Cryptocurrency Strategy Based on Multiple IndicatorsPine Script · Machine learning · 45m
- Parabolic SAR and CCI Strategy with EMA Exit for Gold TradingPine Script · Machine learning · 1d
- Dual CCI Quantitative StrategyPine Script · Machine learning · 1h
- Multi indicator Combination StrategyPine Script · Machine learning · 1d