Skip to content

Latest commit

 

History

History
169 lines (98 loc) · 8 KB

基于布林带的量化交易策略Bollinger-Bands-Based-Quantitative-Trading-Strategy.md

File metadata and controls

169 lines (98 loc) · 8 KB

Name

基于布林带的量化交易策略Bollinger-Bands-Based-Quantitative-Trading-Strategy

Author

ChaoZhang

Strategy Description

IMG

[trans]

概述

本策略基于布林带指标构建交易策略,实现在比特币期货1分钟时间周期上进行自动化交易。当价格突破布林带下限时做多,当价格突破布林带上限时做空,实现获利。

策略原理

该策略使用55个周期的布林带指标,带宽系数设置为4。布林带中线为55日简单移动平均线,上轨线和下轨线分别为中线+4倍标准差和中线-4倍标准差。当价格跌破下轨线时,做多入场;当价格涨破上轨线时,做空入场。

做多信号发出后,策略会在下轨线价格位置设置止损单。做空信号发出后,策略会在上轨线价格位置设置止损单。没有设置止盈单。

优势分析

该策略利用了布林带指标判断超买超卖的能力,合理确定入场时机。带宽系数设置为4,避免了过于频繁交易的问题。回测结果显示,在比特币1分钟时间周期,该策略实现了80%以上的盈利概率,效果显著。

相比其他指标,布林带指标对市场波动具有很好的适应性,能够自动调整带宽capture不同时期的股票波动。这使得该策略getParameter具有很强的鲁棒性。

此外,策略只依赖布林带一个指标,非常简单,适合量化交易的要求。

风险分析

该策略主要风险在于布林带指标判断市场超买超卖的效果会受到巨大市场行情的影响。在牛市中,股票可能长期保持高位运行,布林带上轨难以形成有效阻力;同样,在熊市中,股票可能长期处于低位,布林带下轨难以提供有效支撑。这都可能导致策略产生失效的交易信号。

此外,止损位置直接设置在布林带上下轨可能过于接近,无法给予策略足够的空间,进而被反转价格波动击出场外。

优化方向

该策略可以在以下几个方面进行优化:

  1. 结合其他指标判断效果。例如KDJ,MACD等指标可以辅助判断极端超买超卖情况,修正交易信号。

  2. 设置追踪止损来锁定利润。相比静态止损,追踪止损可以根据价格波动来适当调整止损位置。

  3. 优化参数。可以测试不同周期和带宽参数的布林带,找到最佳参数组合。也可以结合优化算法寻找最优参数。

  4. 区分市场行情环境调整参数。证券市场分为三种环境:牛市,熊市和盘整市。所以还可以根据行情分别设定交易参数。

  5. 添加高级的杠杆管理策略。通过动态调整杠杆数来控制策略的风险状况。

总结

本策略通过布林带指标获取市场超买超卖信号,简单清晰的交易逻辑是其最大优势。总的来说,这是一种非常实用的短线量化策略。我们可以在此基础上进行多方面的优化,进一步完善该策略,实现长期稳定获利。

||

Overview

This strategy builds a trading strategy based on the Bollinger Bands indicator to achieve automated trading on bitcoin futures 1-minute time frame. It goes long when the price breaks through the lower bound of the Bollinger Bands and goes short when the price breaks through the upper bound of the Bollinger Bands to make profits.

Strategy Principle

The strategy uses the Bollinger Bands indicator with 55 periods and a bandwidth coefficient set to 4. The middle line of the Bollinger Bands is the 55-day simple moving average, and the upper and lower lines are the middle line +4 times the standard deviation and the middle line -4 times the standard deviation respectively. When the price falls below the lower line, go long; when the price rises above the upper line, go short.

After the long signal is triggered, the strategy will set a stop loss order at the price of the lower line. After the short signal is triggered, the strategy will set a stop loss order at the price of the upper line. No take profit orders are set.

Advantage Analysis

The strategy utilizes the Bollinger Bands indicator's ability to determine overbought and oversold conditions to reasonably determine entry timing. The bandwidth coefficient is set to 4 to avoid excessively frequent trading. Backtest results show that on the bitcoin 1-minute time frame, the strategy achieves a profitable probability of over 80%, with significant effect.

Compared with other indicators, the Bollinger Bands indicator adapts very well to market fluctuations and can automatically adjust the bandwidth to capture volatility in different periods. This makes the strategy's parameters very robust.

In addition, the strategy relies solely on the Bollinger Bands indicator, which is very simple and meets the requirements for quantitative trading.

Risk Analysis

The main risk of this strategy lies in the fact that the Bollinger Bands indicator's effect of judging overbought and oversold market conditions can be affected by huge market moves. In a bull market, stock prices may run high for an extended period, making it difficult for the upper rail to form effective resistance. Similarly, in a bear market, stock prices may stay low for an extended period, making it hard for the lower rail to provide effective support. All this can lead to invalid trading signals being generated by the strategy.

In addition, setting stop loss directly at the upper and lower rails of the Bollinger Bands may be too close, failing to give the strategy enough room and thus getting knocked out by price fluctuations.

Optimization Directions

The strategy can be optimized in the following aspects:

  1. Combine with other indicators. Indicators like KDJ and MACD can help judge extreme overbought/oversold conditions to modify trading signals.

  2. Set trailing stop loss to lock in profits. Compared with static stop loss, trailing stop loss can adjust stop loss position appropriately based on price fluctuation.

  3. Optimize parameters. Different periods and bandwidth parameters of Bollinger Bands can be tested to find the optimal parameter combination. Optimization algorithms can also be used to find the optimal parameters.

  4. Adjust parameters according to market conditions. The market has three states: bull, bear and range-bound. So parameters can be set separately based on market conditions.

  5. Add advanced leverage management strategies. Manage the strategy's risk profile by dynamically adjusting leverage.

Conclusion

The biggest strength of this strategy is its simple and clear trading logic of getting overbought/oversold signals from the Bollinger Bands indicator. Overall, it is a very practical short-term quantitative strategy. We can further improve it by optimizing it in many ways to achieve long-term steady profits.

[/trans]

Strategy Arguments

Argument Default Description
v_input_1 55 length
v_input_2 4 mult

Source (PineScript)

/*backtest
start: 2023-11-27 00:00:00
end: 2023-12-27 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("Kozlod - BB Strategy - 1 minute", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)

// 
// author: Kozlod
// date: 2019-05-29
// BB - XBTUDS - Bitmex - 1m
// https://www.tradingview.com/u/Kozlod/
// https://t.me/quantnomad
//

source = close
length = input(55, minval=1)
mult = input(4, minval=0.001, maxval=50)

basis = sma(source, length)
dev = mult * stdev(source, length)

upper = basis + dev
lower = basis - dev

plot(upper)
plot(lower)

buyEntry  = crossover(source, lower)
sellEntry = crossunder(source, upper)

if (crossover(source, lower))
    strategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands",  comment="BBandLE")
else
    strategy.cancel(id="BBandLE")

if (crossunder(source, upper))
    strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", comment="BBandSE")
else
    strategy.cancel(id="BBandSE")

Detail

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

Last Modified

2023-12-28 15:54:07