9 day EMA Breakout Pullback Trading Strategy
This strategy uses the 9-day EMA as the judgement indicator, determining market direction based on price breakouts of the EMA, belonging to a typical trend following strategy. It enters long/short on EMA breakouts…
Overview
This strategy uses the 9-day EMA as the judgement indicator, determining market direction based on price breakouts of the EMA, belonging to a typical trend following strategy. It enters long/short on EMA breakouts, and exits for profit when price pulls back.
Strategy Logic
The 9-day EMA line is computed for trend judgement. When price opens below and closes above the EMA, an upward breakout is identified for going long. When price opens above and closes below the EMA, a downward breakout is identified for going short.
After entry, take profit stops are set near the high/low of that bar, i.e. take profit for upside breakouts is the high of previous bar, and for downside breakouts is the low of previous bar. Trades are closed when price hits the take profit levels.
Advantage Analysis
The strategy uses EMA to determine trends and enters on EMA breakouts, effectively tracking trends. The nearby take profit points aim to capture short-term pullbacks. The strategy logic is simple and direct, easy to automate.
The EMA period is customizable for flexibility. The direct stop profit approach avoids holding losing trades for too long. Backtests show good performance during obvious trending periods.
Risk Analysis
The reliance on a single EMA indicator makes trend identification difficult during ranging markets, with the risk of excessive false signals. The nearby stop profits also fail to capture adequate trend moves.
Tuning the EMA period, or incorporating additional technical indicators could help improve judgement. Optimizing the stop profit, via trail stops, dynamic exits etc, could also aid stability. Controlling per trade position sizes via capital management would further limit risks.
Optimization Directions
Test and optimize EMA parameters to find more suitable periods.
Add volume, volatility or other judgement rules.
Optimize stop profit strategies, such as trail stops, dynamic exits.
Combine more technical indicators to form an ensemble system.
Apply machine learning for trend direction forecasting.
Adopt strict capital management to control per trade position sizing.
Summary
The strategy is a simple EMA breakout pullback system, which is clear and easy to implement, but limited relying on single EMA. Incorporating more technical indicators could improve robustness. Overall it provides a basic quant trading strategy idea.
Source Pine Script
/*backtest
start: 2023-01-01 00:00:00
end: 2023-09-19 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy("larry willians teste2", overlay=true)
//Window of time
start = timestamp(2019, 00, 00, 00, 00) // backtest start window
finish = timestamp(2019, 12, 31, 23, 59) // backtest finish window
window() => true // create function "within window of time"
ema9=ema(close,9) // Ema de 9 periodos
//Condições de compra
c1= (open< ema9 and close > ema9) //abrir abaixo da ema9 e fechar acima da ema9
if(window())
if(c1)
strategy.entry("Compra", true, stop = high) // Coloca ordem stopgain no topo anterior
else
strategy.cancel("Compra") // Cancela a ordem se o proximo candle não "pegar"
//codições de venda
v1= (open> ema9 and close < ema9) // abrir acima da ema9 e fechar abaixo ema9
if(window())
if (v1)
strategy.exit("Venda", from_entry = "Compra", stop = low) // Saida da entrada com stop no fundo anterior
else
strategy.cancel("Venda") //Cancela a ordem se o proximo candle não "pegar"
Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-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/9-day-EMA-Breakout-Pullback-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 Multi Period Trading Strategy Based on Wave Trend Momentum BreakoutPine Script · Breakout · 2h
- BB Breakout StrategyPine Script · Breakout · 1d
- BMSB Breakout Strategy BMSBPine Script · Breakout · 1h
- Bollinger Band T3 Moving Average StrategyPine Script · Breakout · 10m
- Bollinger Bands Dual track Breakthrough StrategyPine Script · Breakout · 30m
- Bollinger Breakout StrategyPine Script · Breakout · 30m