Name
基于布林带B指标的长线交易策略Long-Term-Trading-Strategy-Based-on-Bollinger-Bands-B-Indicator
Author
ChaoZhang
Strategy Description
本策略基于布林带%B指标设计交易信号,在%B值低于设定阈值时做多,采用动态加仓的方式追踪趋势,达到预设止盈止损条件后平仓。该策略适用于识别突破下行布林带支撑位后的反弹行情。
- 计算N日布林带的中轨、上轨、下轨
- 计算%B值:(收盘价-下轨)/(上轨-下轨)
- 当%B值低于设定阈值(默认为0)时,做多
- 以开仓价格为基准,计算止盈线(默认为开仓价格的105%)和止损线(默认为开仓价格的95%)
- 在开仓后,只要符合条件就继续加仓
- 最先触发的止盈止损条件决定平仓
该策略具有以下优势:
- 使用%B指标识别布林带下轨支撑反弹点位,具有较高的效率
- 采用动态加仓方式,能够追踪趋势获利
- 止盈止损条件清晰,有利于风险控制
该策略也存在一些风险:
- %B指标发出虚假信号的概率较大,需要结合其他指标进行确认
- 震荡行情中止损可能较频繁
- 加仓过于激进可能带来更大的风险
对应解决方法:
- 与KD、MACD等指标组合使用,确保交易信号的可靠性
- 调整止损位置,扩大承受震荡的空间
- 合理控制单次加仓比例,防止风险失控
该策略还可从以下方面进行优化:
- 测试不同参数组合,寻找最佳参数
- 优化加仓逻辑,在盈利达到一定比例后停止加仓
- 增加流动性过滤,避免低流动性股票的误交易
本策略总体来说是一个较为稳健的长线交易策略。识别能力和参数优化都还有提升的空间,若结合其他指标过滤信号,控制好仓位管理,该策略在趋势行情中可以获得较好的回报。
||
This strategy generates trading signals based on the Bollinger Bands %B indicator. It goes long when the %B value falls below a preset threshold and adopts a dynamic position averaging approach to follow the trend until take profit or stop loss is triggered. The strategy is suitable for identifying pullback opportunities after the support of the Bollinger lower band is broken.
- Calculate the middle band, upper band and lower band of N-day Bollinger Bands
- Calculate %B value: (%B = (Close - LowerBB)/(UpperBB - LowerBB) )
- Go long when %B value falls below the threshold (default is 0)
- Set take profit based on entry price (default is 105% of entry price) and stop loss (default is 95% of entry price)
- Add to the position as long as conditions are met after opening position
- The first triggered take profit or stop loss closes the position
The advantages of this strategy are:
- %B indicator efficiently identifies pullback points after lower band support
- Dynamic position averaging tracks the trend for greater profit
- Clear take profit and stop loss conditions facilitate risk control
There are also some risks associated with this strategy:
- Higher probability of false signals from %B
- More frequent stop loss triggers during ranging markets
- Aggressive averaging risks uncontrolled loss
Solutions:
- Combine with indicators like KD and MACD to confirm signal reliability
- Adjust stop loss placement to withstand market volatility
- Control averaging pace to avoid risk explosion
The strategy can be further optimized in the following areas:
- Test different parameter combinations for best results
- Optimize averaging logic, e.g. stop adding after certain profit target achieved
- Add liquidity filter to prevent errant trading in low liquidity stocks
Overall this is a relatively robust long-term trading strategy. There is room for improvement in both signal accuracy and parameter tuning. When combined with additional signal filtering and prudent position sizing, this strategy can achieve decent results in trending markets.
[/trans]
Strategy Arguments
Argument | Default | Description |
---|---|---|
v_input_int_1 | 20 | BB Length |
v_input_1_close | 0 | Source: close |
v_input_float_1 | 2 | Deviation |
v_input_2 | 5 | Take Profit |
v_input_3 | 100 | Stop Loss |
v_input_4 | timestamp(01 Jan 2023 00:00 +0000) | Start Date |
v_input_5 | timestamp(01 Jan 2024 00:00 +0000) | End Date |
v_input_float_2 | false | hangi degerin altinda long alsin |
Source (PineScript)
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Bollinger Bands %B Long Strategy", shorttitle="BB %B Long Strategy", overlay=true)
// Girdiler
length = input.int(20, title="BB Length")
src = input(close, title="Source")
dev = input.float(2.0, title="Deviation")
kar_hedefi = input(5, title="Take Profit")
zarar_durumu = input(100, title="Stop Loss")
start_date = input(timestamp("01 Jan 2023 00:00 +0000"), "Start Date")
end_date = input(timestamp("01 Jan 2024 00:00 +0000"), "End Date")
altinda_kalirsa_long = input.float(0, title="hangi degerin altinda long alsin")
// Bollinger Bantları %B göstergesi
basis = ta.sma(src, length)
stdDev = ta.stdev(src, length)
upperBand = basis + dev * stdDev
lowerBand = basis - dev * stdDev
percentB = (src - lowerBand) / (upperBand - lowerBand)
// Alım-Satım Sinyalleri
longCondition = percentB < altinda_kalirsa_long
// Kar/Zarar Hesaplama
takeProfit = strategy.position_avg_price * (1 + kar_hedefi / 100)
stopLoss = strategy.position_avg_price * (1 - zarar_durumu / 100)
// Long (Alım) İşlemi
if (longCondition )
strategy.entry("Long", strategy.long)
strategy.exit("Take Profit/Stop Loss", "Long", limit=takeProfit, stop=stopLoss)
// Take Profit Seviyesi Çizgisi
plot(takeProfit, title="Take Profit", color=color.green, linewidth=1, style=plot.style_linebr)
Detail
https://www.fmz.com/strategy/440695
Last Modified
2024-02-01 11:15:44