0bps

Strategy vault / Breakout

Momentum Breakout Strategy 439229

This strategy combines EMA lines, MACD indicator and single-day gain to identify market breakthrough signals and implement a momentum trading strategy to buy low and sell high.

Author
ChaoZhang
Complexity
Intermediate · 63 lines
Parameters
9
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

Overview

This strategy combines EMA lines, MACD indicator and single-day gain to identify market breakthrough signals and implement a momentum trading strategy to buy low and sell high.

Strategy Principle

When the fast EMA line crosses over the slow EMA line, it is considered that the market is in an upward trend and a buy signal is generated. When the difference of MACD indicator crosses over the 0 axis, a buy signal is also generated to open long positions.

In addition, if the close price of a single day rises more than 10% compared to the open price, a buy signal will also be generated to chase the breaking market trend.

After opening positions, if the price falls more than 10%, stop loss will be triggered. If the profit reaches 45%, take profit will be triggered.

Advantage Analysis

This is a typical trend following strategy that can capture the uptrend after a strong momentum breakthrough, with great profit potential. The main advantages are:

  1. EMA lines implement trend judgment to avoid opening positions during market consolidation.
  2. MACD indicator ensures more reliable buy signals.
  3. Single day gain condition captures trend outbreak.
  4. Reasonable stop loss and take profit settings help control risks.

Risk Analysis

Although reasonably designed, some risks still exist:

  1. Improper breakthrough signal judgment may lead to short losses.
  2. Market rebound may also generate false signals.
  3. Oversize stop loss setting increases loss risk.
  4. Insufficient follow-up trend after breakthrough may lead to insufficient profit.

To reduce the above risks, we can consider optimizing the moving stop loss strategy or adding other indicators like volume to filter signals.

Optimization Directions

There is still room for further optimization:

  1. Add volume indicator to ensure enough trading volume supporting the trend.
  2. Optimize MACD parameters to improve indicator sensitivity.
  3. Test different combinations of EMA periods.
  4. Add adaptive stop loss mechanism.
  5. Optimize take profit points for more efficient money management.

Through parameter tuning, indicator combination and other methods, the stability and profitability of this strategy can be greatly improved.

Conclusion

In general, this strategy is simple, practical and with great profit potential. By judging market breakthrough points, it can effectively capture uptrends, and the drawdown control is also reasonable. In future optimization, continuingly improving parameter adjustment and stop loss/take profit design can make it a worthwhile long-term quantitative trading strategy.

Parameters

NameDefaultWhat it controls
v_input_15fastLength
v_input_212slowLength
v_input_350baseLength
v_input_49MACDLength
v_input_512MACDfast
v_input_626MACDslow
v_input_710Gain %
v_input_810Stop Loss %
v_input_945Profit %

Source Pine Script

/*backtest
start: 2023-01-11 00:00:00
end: 2024-01-17 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("Alt Coins", overlay=true)

//Simple Alt Coin Trading Strategy//
// by @ShanghaiCrypto //

////EMA////
fastLength = input(5)
slowLength = input(12)
baseLength = input(50)
price = close

emafast = ema(price, fastLength)
emaslow = ema(price, slowLength)
emabase = ema(price, baseLength)

///MACD////
MACDLength = input(9)
MACDfast = input(12)
MACDslow = input(26)
MACD = ema(close, MACDfast) - ema(close, MACDslow)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD

////PUMP////
OneCandleIncrease = input(10, title='Gain %')
pump = OneCandleIncrease/100

////Profit Capture and Stop Loss//////
stop = input(10.0, title='Stop Loss %', type=float)/100
profit = input(45.0, title='Profit %', type=float)/100
stop_level = strategy.position_avg_price * (1 - stop)
take_level = strategy.position_avg_price * (1 + profit)

////Entries/////
if crossover(emafast, emaslow)
    strategy.entry("Cross", strategy.long, comment="BUY")

if (crossover(delta, 0))
    strategy.entry("MACD", strategy.long, comment="BUY")
    
if close > (open + open*pump)
    strategy.entry("Pump", strategy.long, comment="BUY")

/////Exits/////
strategy.exit("SELL","Cross", stop=stop_level, limit=take_level)
strategy.exit("SELL","MACD", stop=stop_level, limit=take_level)
strategy.exit("SELL","Pump", stop=stop_level, limit=take_level)

////Plots////
plot(emafast, color=green)
plot(emaslow, color=red)
plot(emabase, color=yellow)
plot(take_level, color=blue)
plot(stop_level, color=orange)

Published by ChaoZhang on the FMZ strategy square · last modified 2024-01-18. 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/Momentum-Breakout-Strategy-439229.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