Momentum Oscillating Moving Average Trading Strategy Based on Buffered Bollinger Bands
This strategy constructs a price channel based on the Bollinger Bands indicator and the Momentum Oscillating Moving Average indicator, generating trading signals when the price breaks through the upper or lower…

Overview
This strategy constructs a price channel based on the Bollinger Bands indicator and the Momentum Oscillating Moving Average indicator, generating trading signals when the price breaks through the upper or lower boundary of the channel. By combining the adaptability of Bollinger Bands and the flexibility of momentum oscillators, it can respond timely to changes in market trends.
Strategy Logic
The strategy builds a price channel using the Bollinger middle band and the Momentum Oscillating Moving Average. The middle band adopts 21-period Bollinger middle band. The upper and lower bands stretch up and down for a percentage range respectively. The Momentum Oscillating Moving Average stretches or shrinks near overbought or oversold levels based on the middle band. When price breaks through the upper band, go long. When price breaks through the lower band, go short.
Specifically, the Bollinger middle band is calculated as:
Middle Band = Moving Average of N-period closing price
The upper band and lower band are calculated as:
Upper Band = Middle Band + WidthDev * N-period Bollinger standard deviation
Lower Band = Middle Band - WidthDev * N-period Bollinger standard deviation
Where WidthDev represents the extended percentage range up and down.
The Momentum Oscillating Moving Average stretches or shrinks based on the middle band according to certain rules. When the market becomes overbought or oversold, it extends further away from the middle band to provide more opportunities for going long or going short. When the market calms down, it contracts towards the middle band.
In summary, this strategy depicts a price channel using Bollinger Bands and determines entry timing using the Momentum Oscillating Moving Average, realizing breakout trading. Go long when price breaks out upwards from the Bollinger upper band, and go short when price breaks out downwards from the Bollinger lower band.
Advantage Analysis
Reflects market volatility Bollinger Bands can reflect market volatility and changing trends in real time. The upper and lower bands adapt based on changes in volatility.
Reduces false signals The stretching effect of the Momentum Oscillating Moving Average can effectively reduce false signals generated by Bollinger Bands. By expanding the width of the BB channel and extending holding periods, greater profits can be obtained.
Timely catches trend reversal The crossover of BB upper & lower bands and Momentum Oscillating Moving Average provides advantageous timing and pricing for generating trading signals, which can effectively catch key bull and bear adjustments and timely grasp trend reversals.
Risk Analysis
Improper BB parameters Improper settings of BB parameters like calculation period and standard deviation multiplier may lead to too wide or too narrow spacing between the bands, generating excessive false signals and undermining the stability of the strategy.
Excessive oscillation amplitude Excessively large oscillation amplitude of the Momentum Oscillating Moving Average may result in stop loss points being too distant, increasing loss risk.
Delayed reversal
When the market is oscillating or trendless, trading signals from BB and Momentum Oscillating Moving Average may lag, failing to reflect price changes in time, causing delayed reversal risk.
Optimization Directions
Optimize BB parameters Test different periods, standard deviation multipliers to find optimal parameter combinations that provide better signal frequency and fewer false signals.
Optimize Momentum Oscillating Moving Average parameters Test different oscillation amplitudes and periods to find parameters that better catch trends and reduce signal lag.
Add filter conditions Add filters like trading volumes based on crossover signals to exclude inefficient trade signals.
Strategy combination Combine this strategy with other stop loss strategies or machine learning strategies to further control risks and improve stability.
Summary
This strategy combines the strengths of adaptive Bollinger Bands and Momentum Oscillating Moving Average, achieving an integration of trend following and catching trend reversals. By balancing market volatility and trading signal flexibility, it realizes stable and effective breakout trading. Parameter optimization and risk control are also critical to test and tune according to varying market environments.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 210 | HullMA Period |
| v_input_2 | 200 | Cloud Width |
| v_input_3_ohlc4 | 0 | Price data: ohlc4 | high | low | open | hl2 | hlc3 | hlcc4 | close |
| v_input_4 | true | From Month |
| v_input_5 | true | From Day |
| v_input_6 | 2017 | From Year |
| v_input_7 | true | To Month |
| v_input_8 | true | To Day |
| v_input_9 | 9999 | To Year |
Source Pine Script
/*backtest
start: 2022-12-29 00:00:00
end: 2024-01-04 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
// Hull Cloud v2 by SEASIDE420
strategy("Hull Moving Average Cloud v2", shorttitle="hull_cloud_v2", overlay=true, commission_type=strategy.commission.percent, commission_value=0.075, default_qty_type=strategy.percent_of_equity, max_bars_back=200, default_qty_value=100, calc_on_order_fills= true, calc_on_every_tick=true, pyramiding=0)
hullperiod=input(title="HullMA Period",defval=210, minval=1)
Width=input(title="Cloud Width",defval=200, minval=2)
price=input(ohlc4,title="Price data")
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
FromYear = input(defval = 2017, title = "From Year", minval = 2017)
ToMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToYear = input(defval = 9999, title = "To Year", minval = 2017)
start = timestamp(FromYear, FromMonth, FromDay, 00, 00)
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59)
window() => true
n2ma=2*wma(price,round(hullperiod/2))
nma=wma(price,hullperiod)
diff=n2ma-nma
sqn=round(sqrt(hullperiod))
n2ma1=2*wma(price[1],round(hullperiod/2))
nma1=wma(price[1],hullperiod)
diff1=n2ma1-nma1
n1=wma(diff,sqn)
n2=wma(diff1,sqn)
Hull_Line=n1-n1[1]/n2[1]
Hull_retracted=if(n1>n2)
Hull_retracted=Hull_Line-Width
else
Hull_retracted=Hull_Line+Width
c1=(Hull_retracted*n1)/price[1]
c2=(Hull_retracted*n2)/price[1]
c4=c1>c2?green:red
c2p=plot(c2, color=black, linewidth=1)
c3p=plot(price, color=black, linewidth=1)
fill(c3p, c2p, color=c4, transp=75)
plot(cross(c1, c2) ? c1 : na, style = circles,color=c4, linewidth = 4)
if (price<c2)
strategy.close("BUY", when=window())
if (price>c2)
strategy.close("SELL", when=window())
if (price[1]>c2 and price[1]>c1)
strategy.entry("BUY",strategy.long, when=window())
if (price[1]<c1 and price[1]<c2)
strategy.entry("SELL",strategy.short, when=window())// /L'-,
// ,'-. ` ```` / L '-,
// . _,--dMMMM\ ` ` ` '`.. / '-,
// : _,--, )MMMMMMMMM),. ` ,<> /_ '-,'
// ; ___,--. \MM( `-' )M//MM\ ,',.; .-'* ; .'
// | \MMMMMM) \MM\ ,dM//MMM/ ___ < ,; `. )`--' /
// | \MM()M MMM)__ /MM(/MP' ___, \ \ ` `. `. /__, ,'
// | MMMM/ MMMMMM( /MMMMP'__, \ | / `. `-,_\ /
// | MM /MMM---' `--'_ \ |-' |/ `./ .\----.___
// | /MM' `--' __,- \"" |-' |_, `.__) . .F. )-.
// | `--' \ \ |-' |_, _,-/ J . . . J-'-. `-.,
// | __ \`. | | | \ / _ |. . . . \ `-. F
// | ___ / \ | `| ' __ \ | /-' F . . . . \ '`
// | \ \ \ / | __ / \ | |,-' __,- J . . . . . \
// | | / |/ __,- \ ) \ / |_,- __,--' |. .__.----,'
// | |/ ___ \ |'. |/ __,--' `.-;;;;;;;;;\
// | ___ \ \ | | ` __,--' /;;;;;;;;;;;;.
// | \ \ |-'\ ' __,--' /;;;;;;;;;;;;;;\
// \ | | / | __,--' `--;;/ \;-'\
// \ | |/ __,--' / / \ \
// \ | __,--' / / \ \
// \|__,--' _,-;M-K, ,;-;\
// <;;;;;;;; '-;;;;
// :DPublished by ChaoZhang on the FMZ strategy square · last modified 2024-01-05. 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.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Momentum-Oscillating-Moving-Average-Trading-Strategy-Based-on-Buffered-Bollinger-Bands.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- 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
- ADX Momentum Trend StrategyPine Script · Momentum · 10m
- Advanced Multi Indicator Trend Following and Momentum Quantitative Trading StrategyPine Script · Momentum · 1h
- Bollinger Bands Momentum Trend Following Quantitative StrategyPine Script · Momentum · 1d
- Momentum Oscillator Bollinger Band RSI Trading StrategyPine Script · Momentum · 1m
- Moving Average Candle Regression StrategyPine Script · Momentum · 15m
- Multi Timeframe Unified Strategy Based on Quantitative Momentum and Convergence DivergencePine Script · Momentum · 1d