本策略基于布林带%B指标设计交易信号,在%B值低于设定阈值时做多,采用动态加仓的方式追踪趋势,达到预设止盈止损条件后平仓。该策略适用于识别突破下行布林带支撑位后的反弹行情。
该策略具有以下优势:
该策略也存在一些风险:
对应解决方法:
该策略还可从以下方面进行优化:
本策略总体来说是一个较为稳健的长线交易策略。识别能力和参数优化都还有提升的空间,若结合其他指标过滤信号,控制好仓位管理,该策略在趋势行情中可以获得较好的回报。
/*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)