
连续K线反转突破策略的核心思想是捕捉股价在经过一段时间的连续下跌后出现反转信号并突破重要阻力位的交易机会。该策略通过设置连续下跌K线数量、连续上涨K线数量以及止损条件等参数,在特定条件满足时开仓做多,并在止损条件触发时平仓。
策略的关键在于正确识别反转信号和设置合适的参数。连续下跌多少根K线以及连续上涨多少根K线是两个重要的参数,需要根据回测结果进行优化。此外,止损条件的设置也很关键,既要控制风险,又不能过早止损导致错失机会。
连续K线反转突破策略通过捕捉股价连续下跌后的反转信号来进行交易决策。该策略简单易懂,适合在震荡市和趋势初期使用,通过设置连续K线数量和止损条件等参数,可以灵活适应不同的市场状况。但是,该策略也存在一些局限性,如对长期趋势行情的适应性一般,缺乏头寸管理和资金管理等。
在实际应用中,需要根据市场特点和自己的风险偏好,对策略进行优化和改进。例如,优化连续K线数量和止损条件的设置,加入多空双向交易,引入头寸管理和资金管理,以及与其他技术指标和交易信号相结合等。这样可以在提高策略盈利能力的同时,控制风险,实现稳定的投资回报。
总的来说,连续K线反转突破策略是一个简单实用的交易策略,值得在实践中进一步探索和优化。但是,任何策略都不是万能的,投资者还需要结合自己的经验和判断,审慎决策,严格执行,才能在市场中长期立于不败之地。
/*backtest
start: 2024-02-01 00:00:00
end: 2024-02-29 23:59:59
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Bottom Out Strategy", overlay=true)
consecutiveBarsUp = input(2)
consecutiveBarsDown = input(3)
price = close
ups = 0.0
ups := price > price[1] ? nz(ups[1]) + 1 : 0
dns = 0.0
dns := price < price[1] ? nz(dns[1]) + 1 : 0
var entry_bar_index = 1000000
var active = false
var stop_loss = 0.0
// === INPUT BACKTEST RANGE ===
i_from = input(defval = timestamp("01 Jan 2023 00:00 +0000"), title = "From")
i_thru = input(defval = timestamp("01 Mar 2024 00:00 +0000"), title = "Thru")
// === FUNCTION EXAMPLE ===
date() => true
entry_condition() =>
date() and dns[2] >= consecutiveBarsDown and ups >= consecutiveBarsUp and not active
exit_condition() =>
date() and active and (close < nz(stop_loss) or close < high - 2 * ta.atr(7))
if (entry_condition())
strategy.entry("ConsDnLong", strategy.long, comment="CDLEntry")
entry_bar_index := bar_index
active := true
stop_loss := math.min(close, close[1], close[2])
// log.info("Entry at bar {0}, close={1}, stop_loss={2} ", entry_bar_index, close, stop_loss)
if (exit_condition())
strategy.close("ConsDnLong", comment = "CDLClose")
// log.info("Close at bar {0}", bar_index)
entry_bar_index := 1000000
active := false
// if (dns >= consecutiveBarsDown)
// strategy.entry("ConsDnSE", strategy.short, comment="ConsDnSE")
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)
plot(high - 2* ta.atr(7))