0bps

Strategy vault / Breakout

Bollinger Crossing Death Golden Strategy

This strategy is a Bollinger Bands crossover strategy based on the Bollinger Bands indicator. By adjusting the parameters of Bollinger Bands, it is optimized for gold trading. It generates buy signals when the price…

Author
ChaoZhang
Complexity
Starter · 41 lines
Parameters
2
Backtest bar
1h · intraday
Tested on
BTC/USDT · futures

IMG

Overview

This strategy is a Bollinger Bands crossover strategy based on the Bollinger Bands indicator. By adjusting the parameters of Bollinger Bands, it is optimized for gold trading. It generates buy signals when the price closes above the upper band and sell signals when the price closes below the lower band.

Strategy Logic

The strategy uses Bollinger Bands with a length of 50 and a multiplier of 2.5. The middle band of the Bollinger Bands is the SMA line of the price, the upper band is the middle band plus the multiplier of the standard deviation, and the lower band is the middle band minus the multiplier of the standard deviation.

When the price closes above the upper band, a buy signal is generated. When the price closes below the lower band, a sell signal is generated. It utilizes the feature of narrowing of the Bollinger Bands channels and generates signals when the breakout occurs after channel contraction.

Advantage Analysis

The advantages of this strategy include:

  1. The optimized parameters fit gold trading and profit is steady.

  2. Utilize the channel feature of Bollinger Bands to generate signals after reduced price fluctuation, avoiding missing opportunities.

  3. The crossover system is easy to follow for manual trading.

  4. The graphical display is intuitive to monitor the price movement within the bands.

Risk Analysis

There are also some risks with this strategy:

  1. Inappropriate Bollinger Bands parameters may cause false signals. Parameters need to be tested and optimized.

  2. Frequent trading increases costs and slippage. Parameters can be adjusted to lower trading frequency.

  3. It is easy to hit stop loss when gold fluctuates greatly. Stop loss points can be adjusted or position management can be added.

Optimization

The strategy can be optimized from the following aspects:

  1. Test parameters on different markets and time frames to find the optimal parameter combination.

  2. Add position management module to generate additional entry signals through moving average, channel breakouts, etc.

  3. Add stop loss module, using trailing stops to follow price moves.

  4. Incorporate other indicators to filter out false signals and improve strategy stability.

Conclusion

The strategy optimizes Bollinger Bands for gold trading by adjusting parameters. It utilizes the expansion and contraction of Bollinger Bands to generate signals. There is large room for improvement in parameters optimization, position management, stop loss. Overall, the strategy has simple logic, good stability, and is suitable for manual gold trading.

Parameters

NameDefaultWhat it controls
v_input_150BB Length
v_input_22.5Multiplier

Source Pine Script

/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("Optimized Bollinger Bands Strategy for Gold", overlay=true)

// Bollinger Bands Settings
length = input(50, title="BB Length", minval=1)
mult = input(2.5, title="Multiplier", minval=0.001, maxval=50)

// Bollinger Bands
basis = sma(close, length)
upper = basis + mult * stdev(close, length)
lower = basis - mult * stdev(close, length)

// Plotting
plot(upper, color=color.blue, title="Upper Band", linewidth=2)
plot(lower, color=color.blue, title="Lower Band", linewidth=2)

// Highlight the region between upper and lower bands
bgcolor(upper > lower ? color.new(color.blue, 90) : na)

// Buy Signal with arrow
longCondition = crossover(close, upper)
plotshape(series=longCondition, title="Buy Signal", color=color.green, style=shape.triangleup, text="Buy", location=location.belowbar, size=size.small)

// Sell Signal with arrow
shortCondition = crossunder(close, lower)
plotshape(series=shortCondition, title="Sell Signal", color=color.red, style=shape.triangledown, text="Sell", location=location.abovebar, size=size.small)

// Strategy
strategy.entry("Buy", strategy.long, when=longCondition)
strategy.entry("Sell", strategy.short, when=shortCondition)


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/Bollinger-Crossing-Death-Golden-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