该策略使用布林带(Bollinger Bands)作为主要指标,通过分析价格与上下轨的关系,在特定条件下进行交易。策略的主要思路是:当收盘价突破上轨时做多,突破下轨时做空,同时使用相反信号平仓,以此捕捉价格的波动。
该策略以布林带为核心,通过分析价格与布林带的关系,在特定条件下进行交易。策略逻辑清晰,易于理解和实现,在趋势行情中可以获得较好的收益。但同时也存在一些风险,如频繁交易、参数选择不当等。通过引入其他指标、优化参数、设置止损止盈等方式,可以进一步提升策略的性能,更好地适应不同的市场环境。
/*backtest start: 2023-05-28 00:00:00 end: 2024-06-02 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Bollinger Bands Strategy", overlay=true) src = input(close) length = input.int(34, minval=1) mult = input.float(2.0, minval=0.001, maxval=50) basis = ta.sma(src, length) dev = ta.stdev(src, length) dev2 = mult * dev upper1 = basis + dev lower1 = basis - dev upper2 = basis + dev2 lower2 = basis - dev2 // Long Condition: Close above Upper Bollinger Band longCondition = close > upper1 // Short Condition: Close below Lower Bollinger Band shortCondition = close < lower1 // Strategy Entry and Exit strategy.entry("Long", strategy.long, when = longCondition) strategy.entry("Short", strategy.short, when = shortCondition) // Close Long Position when Short Condition is Met strategy.close("Long", when = shortCondition) // Close Short Position when Long Condition is Met strategy.close("Short", when = longCondition) // Plotting Bollinger Bands plot(basis, color=color.blue) plot(upper1, color=color.new(color.blue, 80)) plot(lower1, color=color.new(color.orange, 80))