资源加载中... loading...

Momentum Oscillating Moving Average Trading Strategy Based on Buffered Bollinger Bands

Author: ChaoZhang, Date: 2024-01-05 12:27:02
Tags:

img

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

  1. 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.

  2. 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.

  3. 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

  1. 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.

  2. 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.

  3. 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

  1. Optimize BB parameters Test different periods, standard deviation multipliers to find optimal parameter combinations that provide better signal frequency and fewer false signals.

  2. Optimize Momentum Oscillating Moving Average parameters Test different oscillation amplitudes and periods to find parameters that better catch trends and reduce signal lag.

  3. Add filter conditions Add filters like trading volumes based on crossover signals to exclude inefficient trade signals.

  4. 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.


/*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,           ,;-;\ 
//                                                     <;;;;;;;;           '-;;;; 
//                                                                                  :D

More