0bps

Strategy vault / Breakout

Breakout Trading System

This strategy is a breakout trading system that mainly buys and sells based on the breakthrough of prices. The system uses Bollinger Bands to determine the price breakthrough area. When the price breaks through the…

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

IMG

Overview

This strategy is a breakout trading system that mainly buys and sells based on the breakthrough of prices. The system uses Bollinger Bands to determine the price breakthrough area. When the price breaks through the lower rail of the Bollinger Band upwards, a buy order will be placed. When the price breaks through the middle rail or lower rail of the Bollinger Band downwards, a sell order will be placed.

Strategy Principle

This strategy uses Bollinger Bands to determine price breakthrough areas. Bollinger Bands consist of a simple moving average line of n days and its standard deviation multiplier. Here we calculate the 20-day moving average of highest price and lowest price to determine the upper and lower rail of Bollinger Bands, as well as the average of upper and lower rail as the baseline.

When the close price breaks through the lower rail upwards, it indicates that the price starts to go up which is a buy signal. When the close price breaks through the middle or lower rail downwards, it indicates that the rising trend ends and positions need to be sold out. This strategy takes advantage of the tendency of prices to continue running up or down after the breakthrough to make profits.

Advantage Analysis

  • The strategy makes use of the trending and inertia of prices which is consistent with the essential characteristics of the market
  • Bollinger Bands clearly indicate breakthrough prices
  • The strategy logic is simple and clear, easy to understand and modify
  • Stop loss conditions can be set to control risks

Risk Analysis

  • Bollinger Bands cannot completely predict price behavior, prices may fluctuate dramatically
  • Breakthrough signals may be wrong, leading to trading losses
  • Relying solely on price breakthroughs to determine trading time can easily be affected by market noise

Solutions:

  • Combine other indicators to confirm breakthrough signals
  • Adjust parameters appropriately to ensure effective breakthrough signals
  • Set stop loss to control single loss

Optimization Directions

  • Test performances under different parameters and select the optimal parameters
  • Incorporate other indicators to filter out false breakouts, such as trading volume
  • Combine trend and reversal strategies for trading in different market environments
  • Optimize based on parameter settings for different varieties
  • Incorporate machine learning algorithms to predict price trends and key price points

Summary

This is a price breakthrough trading strategy based on Bollinger Bands. It takes advantage of the characteristics of price breakthroughs to identify trading opportunities. The advantages are that it is simple, easy to implement; the disadvantages are that there may be false breakouts leading to losses. We can optimize this strategy by adjusting parameters, incorporating other indicators and setting stop loss to achieve good results in backtesting and live trading. In general, this strategy is suitable for market environments that can fully tap the trending tendency of prices.

Parameters

NameDefaultWhat it controls
v_input_120length
v_input_2trueExit Option

Source Pine Script

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

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0

//Break out trading system works best in a weekly chart and daily chart of Nifty and BankNifty
//@version=4

strategy("Eswar New",shorttitle = "ESW")
length = input(20, minval=1)
exit = input(1, minval=1, maxval=2,title = "Exit Option") // Use Option 1 to exit using lower band; Use Option 2 to exit using basis line

lower = lowest(length)
upper = highest(length)
basis = avg(upper, lower)

l = plot(lower, color=color.blue)
u = plot(upper, color=color.blue)
plot(basis, color=color.orange)
fill(u, l, color=color.blue)

longCondition = crossover(close,upper[1])
if (longCondition)
    strategy.entry("Long", strategy.long)

if(exit==1)
    if (crossunder(close,lower[1]))
        strategy.close("Long")

if(exit==2) 
    if (crossunder(close,basis[1]))
        strategy.close("Long")

Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-21. 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/Breakout-Trading-System.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