Skip to content

Latest commit

 

History

History
246 lines (175 loc) · 12.6 KB

缓冲布林带动量震荡移动平均线交易策略Momentum-Oscillating-Moving-Average-Trading-Strategy-Based-on-Buffered-Bollinger-Bands.md

File metadata and controls

246 lines (175 loc) · 12.6 KB

Name

缓冲布林带动量震荡移动平均线交易策略Momentum-Oscillating-Moving-Average-Trading-Strategy-Based-on-Buffered-Bollinger-Bands

Author

ChaoZhang

Strategy Description

IMG [trans]

概述

本策略基于布林带指标和震荡移动平均线指标,构建了一个价格通道,通过通道上下边界的突破来发出交易信号。它融合了布林带的自适应性和震荡指标的灵活性,能够及时捕捉市场趋势的改变。

策略原理

本策略使用布林带中轨和震荡移动平均线构建价格通道。中轨采用21周期的布林中轨,上轨和下轨分别向上和向下延伸一个百分比区间。震荡移动平均线以中轨为基础,在超买超卖区域时进行拉伸或收缩。当价格突破上轨时,做多;当价格突破下轨时,做空。

具体来说,布林中轨计算公式为:

中轨 = N日收盘价的移动平均线 

上轨、下轨计算公式为:

上轨 = 中轨 + WidthDev * 布林带N日标准差  
下轨 = 中轨 - WidthDev * 布林带N日标准差  

其中WidthDev代表向上和向下延伸的百分比区间。

震荡移动平均线以中轨为基础,根据一定规则进行拉伸或收缩。当市场进入超买或超卖状态时,它会延伸离中轨更远,从而扩大做多做空的机会;当市场趋于平静时,它会向中轨收缩。

综上,本策略通过布林带描绘价格通道,再利用震荡移动平均线指标判断入场时机,实现了突破交易。当价格从下向上突破布林上轨时做多;当价格从上向下突破布林下轨时做空。

优势分析

  1. 反映市场波动性 布林带能够实时反映市场的波动性和变化趋势,上下轨会根据波动率的变化进行自适应调整。

  2. 减少虚假信号 震荡移动平均线指标通过“拉伸效应”,可以有效减少布林带产生的虚假信号。它增大布林带通道宽度,延长持仓时间,从而获取更大利润。

  3. 及时捕捉趋势反转 布林带上下轨和震荡移动平均线的交叉为发出交易信号提供了时间和价格优势,这可以有效地捕捉关键的多头和空头调整,及时把握市场趋势反转。

风险分析

  1. 布林带参数设置 布林带的参数如计算周期和标准差倍数等设置不当,会导致上下轨间距过大或过小,产生大量虚假信号,影响策略的稳定性。

  2. 震荡幅度过大 震荡移动平均线的震荡幅度设置过大时,容易导致止损点过远,增加亏损风险。

  3. 反转不及时 当市场处于震荡或者无明确趋势时,布林带和震荡移动平均线指标发出的交易信号可能滞后,无法及时反映价格变化,导致反转不及时的风险。

优化方向

  1. 优化布林带参数
    可以测试不同的周期参数、标准差倍数,选择产生信号次数最佳且虚假信号更少的参数组合。

  2. 优化震荡移动平均线参数 可以测试不同的震荡幅度和震荡周期,选择能捕捉趋势、减少信号滞后的参�数。

  3. 增加过滤条件 可在布林带和震荡移动平均线的交叉信号基础上,加入成交量等辅助指标的过滤,排除一些低效的交易信号。

  4. 策略组合 该策略可与其它跟踪止损策略或机器学习策略组合使用,进一步控制风险,提高稳定性。

总结

本策略基于布林带自适应通道和震荡移动平均线指标,实现了趋势跟踪和趋势反转捕捉的有机结合。它融合了两种指标的优势,既考虑了市场波动率,也兼顾交易信号的灵活性,从而实现稳定而高效的突破交易。当然,参数优化和风险控制也尤为关键,需要根据不同市场环境不断测试和调整。

||

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.[/trans]

Strategy Arguments

Argument Default Description
v_input_1 210 HullMA Period
v_input_2 200 Cloud Width
v_input_3_ohlc4 0 Price data: ohlc4
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 (PineScript)

/*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

Detail

https://www.fmz.com/strategy/437750

Last Modified

2024-01-05 12:27:02