0bps

Strategy vault / Breakout

The Momentum Breakout Strategy 443124

The main idea behind this strategy is to decide when to buy and sell cryptocurrency based on price momentum indicators. It tries to capture trends as price reversals happen and profit from the momentum of price…

Author
ChaoZhang
Complexity
Starter · 59 lines
Parameters
5
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

Overview

The main idea behind this strategy is to decide when to buy and sell cryptocurrency based on price momentum indicators. It tries to capture trends as price reversals happen and profit from the momentum of price movements.

Strategy Logic

The strategy uses two metrics to determine entry and exit signals. The first one is price itself – it checks the highest and lowest prices over the past 10 candlesticks. The second one is a momentum indicator based on price - the %K value.

Specifically, when the price falls below 98% of the highest price over the past 10 candlesticks (buy threshold), the strategy triggers a buy signal. This means a downward breakout has happened. Similarly when the price rises above 102% of the lowest price over the past 10 candlesticks (sell threshold), the strategy triggers a sell signal, meaning an upward breakout has occurred.

This way the strategy can capture reversal points as new trends form in price movement. By tuning the buy/sell thresholds, sensitivity of the strategy to breakout signals can be adjusted.

Advantage Analysis

The biggest advantage of this strategy is that it considers both price level and momentum factors. Relying on momentum indicators allows more reliable capturing of true trend reversals instead of being misled by false breakouts. Specific advantages are:

  1. Filters out noise using momentum metrics to identify real signals
  2. Excellent backtest results with relatively small max drawdown
  3. Frequency can be controlled via adjustable parameters
  4. Risk can be effectively managed by incorporating stop loss

Risk Analysis

Some risks to note with this strategy:

  1. Market crash leading to flash crash that cannot be stopped out
  2. Impact of trading fees and slippage
  3. Parameter misconfiguration resulting in overtrading or missing opportunities

Mitigations:

  1. Employ multifactor models to prevent single indicator failure
  2. Incorporate stop loss to restrict max loss
  3. Optimize parameters to make strategy more robust

Enhancement Opportunities

Further optimizations for the strategy:

  1. Add more filters like volume, Bollinger Bands etc.
  2. Dynamically tune parameters based on machine learning
  3. Incorporate fundamental analysis to adjust strategy around key events
  4. Optimize capital utilization via leverage to amplify returns

Summary

Overall this momentum breakout strategy is well suited for capturing short term trading opportunities in cryptocurrencies. It effectively capitalizes on momentum characteristics of price reversals for profit while controlling risk. Continued refinements to parameters and model can make the strategy more robust for consistent returns.

Parameters

NameDefaultWhat it controls
v_input_1BTCCrypto-monnaie
v_input_2trueCapital de départ
v_input_30.02Seuil d'achat
v_input_40.02Seuil de vente
v_input_50.01Taux de frais

Source Pine Script

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

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © nyxover

//@version=5
strategy("Stratégie d'achat bas/vendre haut", shorttitle="Achat/Vente")

// Paramètres d'entrée
crypto = input("BTC", "Crypto-monnaie")
capital = input(1.0, "Capital de départ")
buy_threshold = input(0.02, "Seuil d'achat")
sell_threshold = input(0.02, "Seuil de vente")
fee_rate = input(0.01, "Taux de frais")

// Balances
var float initial_balance = na
var float current_balance = na

// Fonction pour calculer les frais
calculate_fees(amount) =>
    amount * fee_rate

// Fonction pour acheter
should_buy() =>
    close < ta.highest(close, 10) * (1 - buy_threshold)

// Fonction pour vendre
should_sell() =>
    close > ta.lowest(close, 10) * (1 + sell_threshold)

// Logique de la stratégie
if barstate.isfirst
    initial_balance := capital
    current_balance := capital

if should_buy()
    amount_to_buy = current_balance / close
    fees = calculate_fees(amount_to_buy)
    current_balance := current_balance - amount_to_buy - fees
    strategy.entry("Achat", strategy.long)

if should_sell()
    amount_to_sell = current_balance
    fees = calculate_fees(amount_to_sell)
    current_balance := current_balance - amount_to_sell - fees
    strategy.close("Achat")

// Affichage des informations
plot(initial_balance, color=color.green, title="Capital de départ")
plot(current_balance, color=color.blue, title="Capital actuel")

Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-29. 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/The-Momentum-Breakout-Strategy-443124.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