这是一个结合EMA趋势、轮回位突破和交易时段过滤的量化交易策略。策略主要基于均线趋势方向判断,配合价格在关键轮回位置的突破形态作为交易信号,同时引入交易时段过滤来提高交易质量。策略采用百分比止损止盈方式进行风险控制。
策略的核心逻辑包含以下几个关键要素: 1. 使用20日EMA均线作为趋势判断工具,只在价格位于均线上方做多,位于均线下方做空 2. 在关键轮回位(5美元整数关口)附近寻找吞没形态作为交易信号 3. 仅在伦敦和纽约交易时段内开仓,避开低波动率时期 4. 多头信号需同时满足:看涨吞没形态、价格在EMA上方、处于有效交易时段 5. 空头信号需同时满足:看跌吞没形态、价格在EMA下方、处于有效交易时段 6. 采用1%止损和1.5%止盈的风险收益比进行交易管理
该策略通过结合均线趋势、价格形态和时段过滤等多重机制,构建了一个逻辑严谨的交易系统。虽然存在一定局限性,但通过持续优化和完善,有望进一步提升策略的稳定性和盈利能力。策略适合作为中长期趋势跟踪系统的基础框架,根据实际交易需求进行定制化改进。
/*backtest
start: 2024-12-17 00:00:00
end: 2025-01-16 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=6
strategy("The Gold Box Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=200)
// Inputs
roundNumberInterval = input.int(5, title="Round Number Interval ($)", minval=1)
useEMA = input.bool(true, title="Use 20 EMA for Confluence")
emaLength = input.int(20, title="EMA Length")
// Session times for London and NY
londonSession = input("0300-1200", title="London Session (NY Time)")
nySession = input("0800-1700", title="New York Session (NY Time)")
// EMA Calculation
emaValue = ta.ema(close, emaLength)
// Plot Round Number Levels
roundLow = math.floor(low / roundNumberInterval) * roundNumberInterval
roundHigh = math.ceil(high / roundNumberInterval) * roundNumberInterval
// for level = roundLow to roundHigh by roundNumberInterval
// line.new(x1=bar_index - 1, y1=level, x2=bar_index, y2=level, color=color.new(color.gray, 80), extend=extend.both)
// Session Filter
inLondonSession = not na(time("1", londonSession))
inNYSession = not na(time("1", nySession))
inSession = true
// Detect Bullish and Bearish Engulfing patterns
bullishEngulfing = close > open[1] and open < close[1] and close > emaValue and inSession
bearishEngulfing = close < open[1] and open > close[1] and close < emaValue and inSession
// Entry Conditions
if bullishEngulfing
strategy.entry("Long", strategy.long, comment="Bullish Engulfing with EMA Confluence")
if bearishEngulfing
strategy.entry("Short", strategy.short, comment="Bearish Engulfing with EMA Confluence")
// Stop Loss and Take Profit
stopLossPercent = input.float(1.0, title="Stop Loss (%)", minval=0.1) / 100
takeProfitPercent = input.float(1.5, title="Take Profit (%)", minval=0.1) / 100
strategy.exit("Exit Long", "Long", stop=close * (1 - stopLossPercent), limit=close * (1 + takeProfitPercent))
strategy.exit("Exit Short", "Short", stop=close * (1 + stopLossPercent), limit=close * (1 - takeProfitPercent))