该策略是一个基于RSI(相对强弱指标)的自适应交易系统,通过动态调整超买超卖阈值来优化交易信号的生成。策略的核心创新在于引入了Bufi自适应阈值(BAT)方法,该方法根据市场趋势和价格波动性动态调整RSI的触发阈值,从而提高了传统RSI策略的有效性。
策略的核心是将传统固定阈值RSI系统升级为动态阈值系统。具体实现方式如下: 1. 使用短周期RSI计算市场超买超卖状态 2. 通过线性回归计算价格趋势斜率 3. 利用标准差衡量价格波动程度 4. 将趋势和波动信息整合,动态调整RSI阈值 5. 在上升趋势中提高阈值,下降趋势中降低阈值 6. 当价格偏离均值较大时降低阈值敏感度
策略还包含两个风险控制机制: - 固定周期平仓机制 - 最大损失止损机制
这是一个创新性的自适应交易策略,通过动态阈值优化解决了传统RSI策略的局限性。策略综合考虑了市场趋势和波动性,具有较强的适应性和风险控制能力。虽然存在参数优化等挑战,但通过持续改进和优化,该策略有望在实际交易中取得稳定表现。建议交易者在实盘使用前进行充分的回测和参数优化,并根据具体市场特点进行适当调整。
/*backtest start: 2019-12-23 08:00:00 end: 2024-11-11 00:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © PineCodersTASC // TASC Issue: October 2024 // Article: Overbought/Oversold // Oscillators: Useless Or Just Misused // Article By: Francesco P. Bufi // Language: TradingView's Pine Script™ v5 // Provided By: PineCoders, for tradingview.com //@version=5 title ='TASC 2024.10 Adaptive Oscillator Threshold' stitle = 'AdapThrs' strategy(title, stitle, false, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, slippage = 5) // --- Inputs --- string sys = input.string("BAT", "System", options=["Traditional", "BAT"]) int rsiLen = input.int(2, "RSI Length", 1) int buyLevel = input.int(14, "Buy Level", 0) int adapLen = input.int(8, "Adaptive Length", 2) float adapK = input.float(6, "Adaptive Coefficient") int exitBars = input.int(28, "Fixed-Bar Exit", 1, group = "Strategy Settings") float DSL = input.float(1600, "Dollar Stop-Loss", 0, group = "Strategy Settings") // --- Functions --- // Bufi's Adaptive Threshold BAT(float price, int length) => float sd = ta.stdev(price, length) float lr = ta.linreg(price, length, 0) float slope = (lr - price[length]) / (length + 1) math.min(0.5, math.max(-0.5, slope / sd)) // --- Calculations --- float osc = ta.rsi(close, rsiLen) // Strategy entry rules // - Traditional system if sys == "Traditional" and osc < buyLevel strategy.entry("long", strategy.long) // - BAT system float thrs = buyLevel * adapK * BAT(close, adapLen) if sys == "BAT" and osc < thrs strategy.entry("long", strategy.long) // Strategy exit rules // - Fixed-bar exit int nBar = bar_index - strategy.opentrades.entry_bar_index(0) if exitBars > 0 and nBar >= exitBars strategy.close("long", "exit") // - Dollar stop-loss if DSL > 0 and strategy.opentrades.profit(0) <= - DSL strategy.close("long", "Stop-loss", immediately = true) // Visuals rsiColor = #1b9e77 thrsColor = #d95f02 rsiLine = plot(osc, "RSI", rsiColor, 1) thrsLine = plot(sys == "BAT" ? thrs : buyLevel, "Threshold", thrsColor, 1) zeroLine = plot(0.0, "Zero", display = display.none) fill(zeroLine, thrsLine, sys == "BAT" ? thrs : buyLevel, 0.0, color.new(thrsColor, 60), na)