0bps

Strategy vault / Breakout

EMA Breakout Filter Long Only Trading Strategy

This long-only strategy uses an ATR channel to filter fake EMA breakouts for stable trend-following long trades. It focuses solely on long side trading. Strategy Logic: 1. Calculate n-period EMA as intermediate-term…

Author
ChaoZhang
Complexity
Starter · 30 lines
Parameters
1
Backtest bar
7d · position
Tested on
BTC/USDT · futures

This long-only strategy uses an ATR channel to filter fake EMA breakouts for stable trend-following long trades. It focuses solely on long side trading.

Strategy Logic:

  1. Calculate n-period EMA as intermediate-term trend.

  2. Calculate n-period ATR for range channel bands.

  3. Go long when price breaks above channel top.

  4. Exit long when price breaks below channel bottom.

  5. ATR channel filters insignificant or short-term false breakouts.

Advantages:

  1. ATR channel improves reliability of long signals.

  2. Long only reduces complexity and risks.

  3. Simple optimization adapts easily across markets.

Risks:

  1. Unable to profit from short-side moves.

  2. Both EMA and ATR lag, causing poor entry timing.

  3. Hard to sustain signals in prolonged ranges.

In summary, this simple system can perform well in bull trends but requires caution on lagging indicators and ranging markets.

Parameters

NameDefaultWhat it controls
v_input_121Length

Source Pine Script

/*backtest
start: 2020-09-11 00:00:00
end: 2021-04-17 00:00:00
period: 7d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("EMA Long Only Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

len = input(21,  minval=1, title="Length")

price = sma(close, 2)
average = ema(close, len)
diff = atr(len)
bull_level = average + diff
bear_level = average - diff
bull_cross = crossover(price, bull_level)
bear_cross = crossover(bear_level, price)

strategy.entry("Buy", strategy.long, when=bull_cross) 
strategy.close("Buy", when=bear_cross) //strategy.entry("Sell", strategy.short, when=bear_cross)
    
plot(price, title="price", color=green, transp=50, linewidth = 4)
plot(average, title="average", color=red, transp=50, linewidth = 4)
a1 = plot(bull_level, title="bull", color=red, transp=50, linewidth = 1)
a2 = plot(bear_level, title="bear", color=red, transp=50, linewidth = 1)
fill(a2, a1, color=red, transp=95)

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.

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/EMA-Breakout-Filter-Long-Only-Trading-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