Triple EMA Pullback Breakout Trading Strategy
This strategy observes price action around triple EMAs to determine trends and trades breakouts after pullbacks. It aims to capture pullback opportunities within broader uptrends and downtrends. Strategy Logic: 1…
This strategy observes price action around triple EMAs to determine trends and trades breakouts after pullbacks. It aims to capture pullback opportunities within broader uptrends and downtrends.
Strategy Logic:
Set fast, medium and slow EMAs, typically 25, 100, 200 periods.
Price hitting fastest EMA during upside/downside pullback indicates interim bull/bear.
Enter long on bounce off upside pullback when price breaks above fastest EMA. Enter short on bounce off downside pullback when price breaks below fastest EMA.
Color-code buy/sell zones for visual intuition.
Use fixed stop loss and risk/reward ratio for risk management.
Advantages:
Pullback trading enjoys higher win rate.
Triple EMAs discern trends and avoid whipsaws.
Risk/reward ratio enhances performance sustainability.
Risks:
Extended pullbacks may miss best entry timing.
EMA tuning needed to match different periods.
Fixed stops can be too mechanic and need calibration.
In summary, this strategy trades pullback breakouts using triple EMAs to track broader trends. The risk controls help generate steady long-term gains but parameter optimization and pullback judgement remain essential.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_source_1_close | 0 | Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4 |
| v_input_float_1 | 2 | (?Money Management)Ratio Risk/Reward |
| v_input_float_2 | 50 | min of pips (00001.00) for each position |
| v_input_float_3 | 2 | Risk per Trade % |
| v_input_int_1 | 25 | (?Ema Period)Rapide |
| v_input_int_2 | 100 | Moyenne |
| v_input_int_3 | 200 | Lente |
| v_input_bool_1 | true | (?Backtest Time Period)Filter Date Range of Backtest |
| v_input_1 | timestamp(5 June 2022) | Start Date |
| v_input_2 | timestamp(5 July 2022) | End Date |
Source Pine Script
/*backtest
start: 2023-09-04 00:00:00
end: 2023-09-11 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(title="Pullback", overlay=true, initial_capital=1000, slippage=25)
averageData = input.source(close, title="Source")
target_stop_ratio = input.float(title="Ratio Risk/Reward", defval=2, group="Money Management")
security = input.float(50, title='min of pips (00001.00) for each position', group="Money Management")
risk = input.float(2, title="Risk per Trade %", group="Money Management")
riskt = risk / 100 + 1
ema1V = input.int(25, title="Rapide", group="Ema Period")
ema2V = input.int(100, title="Moyenne", group="Ema Period")
ema3V = input.int(200, title="Lente", group="Ema Period")
ema1 = ta.ema(averageData, ema1V)
ema2 = ta.ema(averageData, ema2V)
ema3 = ta.ema(averageData, ema3V)
useDateFilter = input.bool(true, title="Filter Date Range of Backtest",
group="Backtest Time Period")
backtestStartDate = input(timestamp("5 June 2022"),
title="Start Date", group="Backtest Time Period",
tooltip="This start date is in the time zone of the exchange " +
"where the chart's instrument trades. It doesn't use the time " +
"zone of the chart or of your computer.")
backtestEndDate = input(timestamp("5 July 2022"),
title="End Date", group="Backtest Time Period",
tooltip="This end date is in the time zone of the exchange " +
"where the chart's instrument trades. It doesn't use the time " +
"zone of the chart or of your computer.")
inTradeWindow = true
float pricePullAboveEMA_maxClose = na
float pricePullBelowEMA_minClose = na
if ta.crossover(close, ema1)
pricePullAboveEMA_maxClose := close
else
pricePullAboveEMA_maxClose := pricePullAboveEMA_maxClose[1]
if close > pricePullAboveEMA_maxClose
pricePullAboveEMA_maxClose := close
if ta.crossunder(close, ema1)
pricePullBelowEMA_minClose := close
else
pricePullBelowEMA_minClose := pricePullBelowEMA_minClose[1]
if close < pricePullBelowEMA_minClose
pricePullBelowEMA_minClose := close
BuyZone = ema1 > ema2 and ema2 > ema3
SellZone = ema1 < ema2 and ema2 < ema3
longcondition = ta.crossover(close, ema1) and pricePullBelowEMA_minClose > ema3 and pricePullBelowEMA_minClose < ema1
shortcondition = ta.crossunder(close , ema1) and pricePullAboveEMA_maxClose < ema3 and pricePullAboveEMA_maxClose > ema1
float risk_long = na
float risk_short = na
float stopLoss = na
float takeProfit = na
float entry_price = na
risk_long := risk_long[1]
risk_short := risk_short[1]
lotB = (strategy.equity*riskt-strategy.equity)/(close - ema2)
lotS = (strategy.equity*riskt-strategy.equity)/(ema2 - close)
if strategy.position_size == 0 and BuyZone and longcondition and inTradeWindow
risk_long := (close - ema2) / close
minp = close - ema2
if minp > security
strategy.entry("long", strategy.long, qty=lotB)
if strategy.position_size == 0 and SellZone and shortcondition and inTradeWindow
risk_short := (ema2 - close) / close
minp = ema2 - close
if minp > security
strategy.entry("short", strategy.short, qty=lotS)
if strategy.position_size > 0
stopLoss := strategy.position_avg_price * (1 - risk_long)
takeProfit := strategy.position_avg_price * (1 + target_stop_ratio * risk_long)
entry_price := strategy.position_avg_price
strategy.exit("long exit", "long", stop = stopLoss, limit = takeProfit)
if strategy.position_size < 0
stopLoss := strategy.position_avg_price * (1 + risk_short)
takeProfit := strategy.position_avg_price * (1 - target_stop_ratio * risk_short)
entry_price := strategy.position_avg_price
strategy.exit("short exit", "short", stop = stopLoss, limit = takeProfit)
plot(ema1, color=color.blue, linewidth=2, title="Ema Rapide")
plot(ema2, color=color.orange, linewidth=2, title="Ema Moyenne")
plot(ema3, color=color.white, linewidth=2, title="Ema Lente")
p_ep = plot(entry_price, color=color.new(color.white, 0), linewidth=2, style=plot.style_linebr, title='entry price')
p_sl = plot(stopLoss, color=color.new(color.red, 0), linewidth=2, style=plot.style_linebr, title='stopLoss')
p_tp = plot(takeProfit, color=color.new(color.green, 0), linewidth=2, style=plot.style_linebr, title='takeProfit')
fill(p_sl, p_ep, color.new(color.red, transp=85))
fill(p_tp, p_ep, color.new(color.green, transp=85))
bgcolor(BuyZone ? color.new(color.green, 95) : na)
bgcolor(SellZone ? color.new(color.red, 95) : na)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-12. 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/Triple-EMA-Pullback-Breakout-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