0bps

Strategy vault / Breakout

Moving Average Bollinger Band Fusion Trading Strategy

This strategy combines moving averages and Bollinger Bands for dual indicator signal validation to determine and trade trends. Fast and slow moving average crosses provide long/short signals, with Bollinger Band…

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

Overview

This strategy combines moving averages and Bollinger Bands for dual indicator signal validation to determine and trade trends. Fast and slow moving average crosses provide long/short signals, with Bollinger Band breaks as additional confirmation to improve stability.

Strategy Logic

Fast and slow moving averages are calculated. When the fast line crosses above the slow line, a long signal is generated. Below gives a short signal. Bollinger Band upper and lower bands are also calculated. Moving average signals are only confirmed when price also breaks the Bollinger Bands. This avoids whipsaws from false breakouts.

Advantages

  • Dual indicator validation avoids false signals
  • Moving averages determine main trend direction
  • Bollinger Bands confirm quality of breakout
  • Ability to go both long and short provides flexibility

Risks

  • Moving averages and Bollinger Bands have lag
  • Dual conditions limit trade frequency, unsuitable for high frequency trading
  • Exact reversal points cannot be accurately determined
  • Poor parameter tuning risks missing opportunities

Risks can be managed by shortening moving average and Bollinger periods or optimizing parameter combinations.

Enhancements

  • Test different moving average and Bollinger parameter combinations
  • Consider adding stop loss strategies to control losses
  • Optimize logic rules for dual validation
  • Test robustness across different products

Conclusion

This strategy validates signals with dual indicators to reduce false signals, suitable for medium/long-term holding. Further refinements like parameter optimization can improve performance.

Parameters

NameDefaultWhat it controls
v_input_124Bollinger Period Length

Source Pine Script

/*backtest
start: 2023-08-18 00:00:00
end: 2023-09-17 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("MA-Zorrillo",overlay=true)

ma_short= sma(close,8)
ma_long= sma(close,89)

entry_ma = crossover (ma_short,ma_long)
exit_ma = crossunder (ma_short,ma_long) 


BBlength = input(24, minval=1,title="Bollinger Period Length")
BBmult = 2 // input(2.0, minval=0.001, maxval=50,title="Bollinger Bands Standard Deviation")
BBbasis = sma(close, BBlength)
BBdev = BBmult * stdev(close, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev

source = close
entry_bb = crossover(source, BBlower)
exit_bb = crossunder(source, BBupper)


vs_entry = false
vs_exit = false
for i = 0 to 63
    if (entry_bb[i])
        vs_entry :=  true
    if (exit_bb[i])
        vs_exit :=  true
        

entry = entry_ma and vs_entry
exit =  exit_ma and vs_exit

strategy.entry(id="long_ma",long=true,when=entry)
strategy.close(id="long_ma", when=exit)

strategy.entry(id="short_ma",long=false,when=exit)
strategy.close(id="short_ma",when=entry)

Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-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/Moving-Average-Bollinger-Band-Fusion-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