本策略是一个基于价格波动幅度和均线交叉的动量跟踪交易系统。策略主要通过监测价格波动率超过1.91%的异常波动(黑天鹅事件)进行信号触发,同时结合EMA144和EMA169的交叉来确认趋势方向和退出时机。策略特别适用于1-3分钟的短周期交易,能够快速捕捉市场的剧烈波动机会。
策略的核心逻辑包含两个主要部分: 1. 波动率监测:通过计算收盘价与开盘价的绝对差值相对于收盘价的比率来衡量价格波动,当该比率超过1.91%时触发交易信号。 2. 趋势确认:使用EMA144和EMA169的交叉来确认趋势方向,交叉向上则做多,交叉向下则做空。同时还引入了SMA60和SMA20作为辅助指标。
策略在检测到大于1.91%的向上波动时进行做多,检测到向下波动时进行做空。当均线发生反向交叉时,策略会自动平仓以控制风险。
该策略通过结合波动率监测和均线交叉实现了对市场异常波动的快速响应和趋势跟踪。策略设计合理,具有良好的风险控制机制,但仍需要交易者根据实际市场情况进行参数优化和风险管理。建议在实盘交易中从小仓位开始,逐步验证策略在不同市场环境下的表现。
/*backtest
start: 2024-12-05 00:00:00
end: 2024-12-12 00:00:00
period: 45m
basePeriod: 45m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
//黑天鹅警报器,作者():道格拉斯机器人
//适合1分钟-3分钟的k线,发生波动超过百分之二时,自动报警
strategy('黑天鹅警报', overlay=true, initial_capital=10000, currency='USD', default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.075, pyramiding=3)
//-------------------------------------------
//-------------------------------------------
timecondition = timeframe.period == '480' or timeframe.period == '240' or timeframe.period == 'D' or timeframe.period == '720'
// Make input options that configure backtest date range
startDate = input.int(title='Start Date', defval=1, minval=1, maxval=31)
startMonth = input.int(title='Start Month', defval=11, minval=1, maxval=12)
startYear = input.int(title='Start Year', defval=2018, minval=1800, maxval=2100)
endDate = input.int(title='End Date', defval=1, minval=1, maxval=31)
endMonth = input.int(title='End Month', defval=11, minval=1, maxval=12)
endYear = input.int(title='End Year', defval=2031, minval=1800, maxval=2100)
// Look if the close time of the current bar
// falls inside the date range
inDateRange = time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0) and time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0)
// Inputs
a = input(1, title='Key Vaule. \'This changes the sensitivity\'')
c = input(10, title='ATR Period')
h = input(false, title='Signals from Heikin Ashi Candles')
ma60 = ta.sma(close, 60)
ema144 = ta.ema(close, 144)
ema169 = ta.ema(close, 169)
ma20 = ta.sma(close, 20)
plot(ema144, color=color.new(color.yellow, 0), title='144')
plot(ema169, color=color.new(color.orange, 0), title='169')
heitiane = close - open
heitiane := math.abs(heitiane)
heitiane /= close
if inDateRange and heitiane > 0.0191 and close < open // and close>f3
strategy.entry('botsell20', strategy.short, comment='黑天鹅追空' + str.tostring(heitiane))
if ta.crossover(ema144, ema169)
strategy.close('botsell20', comment='平空')
if inDateRange and heitiane > 0.0191 and close > open // and close>f3
strategy.entry('botbuy20', strategy.long, comment='白天鹅追多' + str.tostring(heitiane))
if ta.crossunder(ema144, ema169)
strategy.close('botbuy20', comment='平多')