多重因子反转趋势交易策略是一个专门设计的程序化交易系统,用于识别市场中连续上涨或下跌后的潜在反转点。该策略通过分析价格走势,结合成交量确认和通道带(布林带或肯特纳通道)等多个技术指标,以捕捉市场超买或超卖状态下的反转机会。策略的核心是通过多重因子的综合判断,提高交易信号的可靠性和准确度。
策略主要基于以下三个核心要素进行交易信号的生成: 1. 连续价格变动识别 - 通过设定连续上涨或下跌的K线数量阈值,识别强势趋势的形成 2. 成交量确认机制 - 可选择性地加入成交量分析,要求在价格连续变动期间成交量同步增加,增加信号可靠性 3. 通道突破验证 - 支持布林带和肯特纳通道两种方式,通过价格与通道边界的交互确认超买超卖
交易信号的触发需要满足设定的条件组合。系统会在确认K线收盘后,在符合条件的位置绘制三角形标记并执行相应的多空操作。策略采用账户权益的80%作为每次交易的仓位大小,并考虑了0.01%的交易手续费。
多重因子反转趋势交易策略通过综合分析价格形态、成交量变化和通道突破等多个维度的市场信息,为交易者提供了一个系统化的反转交易方案。策略的优势在于其灵活的参数配置和多维度的信号确认机制,但同时也需要注意市场环境适配和风险控制。通过建议的优化方向,策略有望在实盘交易中取得更好的表现。
/*backtest
start: 2024-12-03 00:00:00
end: 2024-12-10 00:00:00
period: 10m
basePeriod: 10m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(title="The Bar Counter Trend Reversal Strategy [TradeDots]", overlay=true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 80, commission_type = strategy.commission.percent, commission_value = 0.01)
// Initialize variables
var bool rise_triangle_ready = false
var bool fall_triangle_ready = false
var bool rise_triangle_plotted = false
var bool fall_triangle_plotted = false
//Strategy condition setup
noOfRises = input.int(3, "No. of Rises", minval=1, group="STRATEGY")
noOfFalls = input.int(3, "No. of Falls", minval=1, group="STRATEGY")
volume_confirm = input.bool(false, "Volume Confirmation", group="STRATEGY")
channel_confirm = input.bool(true, "", inline="CHANNEL", group="STRATEGY")
channel_type = input.string("KC", "", inline="CHANNEL", options=["BB", "KC"],group="STRATEGY")
channel_source = input(close, "", inline="CHANNEL", group="STRATEGY")
channel_length = input.int(20, "", inline="CHANNEL", minval=1,group="STRATEGY")
channel_mult = input.int(2, "", inline="CHANNEL", minval=1,group="STRATEGY")
//Get channel line information
[_, upper, lower] = if channel_type == "KC"
ta.kc(channel_source, channel_length,channel_mult)
else
ta.bb(channel_source, channel_length,channel_mult)
//Entry Condition Check
if channel_confirm and volume_confirm
rise_triangle_ready := ta.falling(close, noOfFalls) and ta.rising(volume, noOfFalls) and high > upper
fall_triangle_ready := ta.rising(close, noOfRises) and ta.rising(volume, noOfRises) and low < lower
else if channel_confirm
rise_triangle_ready := ta.falling(close, noOfFalls) and low < lower
fall_triangle_ready := ta.rising(close, noOfRises) and high > upper
else if volume_confirm
rise_triangle_ready := ta.falling(close, noOfFalls) and ta.rising(volume, noOfFalls)
fall_triangle_ready := ta.rising(close, noOfRises) and ta.rising(volume, noOfRises)
else
rise_triangle_ready := ta.falling(close, noOfFalls)
fall_triangle_ready := ta.rising(close, noOfRises)
// Check if trend is reversed
if close > close[1]
rise_triangle_plotted := false // Reset triangle plotted flag
if close < close[1]
fall_triangle_plotted := false
//Wait for bar close and enter trades
if barstate.isconfirmed
// Plot triangle when ready and counts exceed threshold
if rise_triangle_ready and not rise_triangle_plotted
label.new(bar_index, low, yloc = yloc.belowbar, style=label.style_triangleup, color=color.new(#9CFF87,10))
strategy.entry("Long", strategy.long)
rise_triangle_plotted := true
rise_triangle_ready := false // Prevent plotting again until reset
if fall_triangle_ready and not fall_triangle_plotted
label.new(bar_index, low, yloc = yloc.abovebar, style=label.style_triangledown, color=color.new(#F9396A,10))
strategy.entry("Short", strategy.short)
fall_triangle_plotted := true
fall_triangle_ready := false
// plot channel bands
plot(upper, color = color.new(#56CBF9, 70), linewidth = 3, title = "Upper Channel Line")
plot(lower, color = color.new(#56CBF9, 70), linewidth = 3, title = "Lower Channel Line")