高频动态开盘区间突破交易策略

ORB RANGE BREAKOUT HFT EST OHLC SL TP
创建日期: 2025-02-21 14:02:59 最后修改: 2025-02-21 14:02:59
复制: 1 点击次数: 115
2
关注
20
关注者

高频动态开盘区间突破交易策略 高频动态开盘区间突破交易策略

概述

该策略是一个基于开盘区间突破的高频交易系统,专注于交易日早盘9:30-9:45期间形成的价格区间。策略通过观察价格是否突破这个15分钟区间来进行交易决策,同时结合了动态的止损和获利设置,以实现风险收益的最优配比。系统还包含了交易日筛选功能,可以根据不同时间段的市场特征来选择性地进行交易。

策略原理

策略的核心逻辑是在每个交易日的开盘后15分钟内(9:30-9:45 EST)建立一个价格区间,记录这段时间内的最高价和最低价。一旦区间形成,策略会在当日12点之前监控价格突破: - 当价格突破区间上轨时,开仓做多,止损设为区间大小的0.5倍,止盈设为止损的3倍 - 当价格突破区间下轨时,开仓做空,止损和止盈的设置原理相同 策略还包含了防止重复交易的机制,确保每天只执行一次交易,并在收盘时平掉所有持仓。

策略优势

  1. 时间效率:策略专注于开盘后最活跃的交易时段,能够捕捉到早盘的大幅波动机会
  2. 风险控制:采用动态的止损止盈设置,根据实际波动幅度来确定风险管理参数
  3. 交易灵活性:提供了按周选择交易日的功能,可以避开特定市场环境下的不利交易日
  4. 执行明确:交易信号清晰,入场出场条件明确,不受主观判断影响
  5. 自动化程度高:全程自动化执行,减少人为干预带来的情绪影响

策略风险

  1. 假突破风险:开盘区间形成后的首次突破可能是假突破,导致止损出场
  2. 时间衰减:策略仅在上午时段交易,可能错过其他时间段的良好机会
  3. 波动依赖:在市场波动较小的日子里,策略可能难以获得足够的盈利空间
  4. 滑点影响:作为高频交易策略,在执行过程中可能面临较大的滑点损失
  5. 市场环境依赖:策略表现可能受到整体市场环境的显著影响

策略优化方向

  1. 引入成交量指标:可以通过观察突破时的成交量来过滤假突破信号
  2. 动态调整交易时间:根据不同品种的活跃时段特征,优化交易时间窗口
  3. 增加趋势过滤:结合更大时间周期的趋势判断,提高交易方向的准确性
  4. 优化止损设置:可以考虑使用动态的ATR指标来设置止损距离
  5. 加入波动率过滤:在开盘前评估波动率水平,决定是否执行当日交易

总结

这是一个设计合理、逻辑严谨的开盘区间突破策略,通过专注于市场最活跃的时段来捕捉交易机会。策略的优势在于其清晰的交易逻辑和完善的风险控制机制,但同时也需要注意假突破和市场环境依赖等潜在风险。通过持续优化和完善,该策略有望在实际交易中取得稳定的收益。

策略源码
/*backtest
start: 2025-01-21 00:00:00
end: 2025-01-24 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Binance","currency":"DOGE_USDT"}]
args: [["MaxCacheLen",580,358374]]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © UKFLIPS69

//@version=6
strategy("ORB", overlay=true, fill_orders_on_standard_ohlc = true)

trade_on_monday = input(false, "Trade on Monday") 
trade_on_tuesday = input(true, "Trade on Tuesday") 
trade_on_wednesday = input(true, "Trade on Wednesday")
trade_on_thursday = input(false, "Trade on Thursday")
trade_on_friday = input(true, "Trade on Friday")
// Get the current day of the week (1=Monday, ..., 6=Saturday, 0=Sunday)
current_day = dayofweek(time) 
current_price = request.security(syminfo.tickerid, "1", close)
// Define trading condition based on the day of the week
is_trading_day = (trade_on_monday and current_day == dayofweek.monday) or
                 (trade_on_tuesday and current_day == dayofweek.tuesday) or
                 (trade_on_wednesday and current_day == dayofweek.wednesday) or
                 (trade_on_thursday and current_day == dayofweek.thursday) or
                 (trade_on_friday and current_day == dayofweek.friday)
// ─── Persistent variables ─────────────────────────
var line  orHighLine       = na   // reference to the drawn line for the OR high
var line  orLowLine        = na   // reference to the drawn line for the OR low
var float orHigh           = na   // stores the open-range high
var float orLow            = na   // stores the open-range low
var int   barIndex930      = na   // remember the bar_index at 9:30
var bool  rangeEstablished = false
var bool  tradeTakenToday  = false  // track if we've opened a trade for the day

// ─── Detect times ────────────────────────────────
is930  = (hour(time, "America/New_York") == 9 and minute(time, "America/New_York") == 30)
is945  = (hour(time, "America/New_York") == 9 and minute(time, "America/New_York") == 45)

// Between 9:30 and 9:44 (inclusive of 9:30 bar, exclusive of 9:45)?
inSession = (hour(time, "America/New_York") == 9 and minute(time, "America/New_York") >= 30 and minute(time, "America/New_York") < 45)

// ─── Reset each day at 9:30 ─────────────────────
if is930
    // Reset orHigh / orLow
    orHigh := na
    orLow  := na
    rangeEstablished := false
    tradeTakenToday  := false
    // Record the bar_index for 9:30
    barIndex930 := bar_index
// ─── ONLY FORM OR / TRADE IF TODAY IS ALLOWED ─────────────────────
if is_trading_day
// ─── Accumulate the OR high/low from 9:30 to 9:44 ─
    if inSession
        orHigh := na(orHigh) ? high : math.max(orHigh, high)
        orLow  := na(orLow)  ? low  : math.min(orLow, low)

// ─── Exactly at 9:45, draw the lines & lock range ─
    if is945 and not na(orHigh) and not na(orLow)

    // Mark that the OR is established
        rangeEstablished := true

// ─── TRADING LOGIC AFTER 9:45, but BEFORE NOON, and if NO trade taken ─
    if rangeEstablished and not na(orHigh) and not na(orLow) 
    // Only trade if it's still BEFORE 12:00 (noon) EST and we haven't taken a trade today
        if hour(time, "America/New_York") < 12 and (not tradeTakenToday)
        // 1) Compute distances for stops & targets
            float stopSize   = 0.5 * (orHigh - orLow)      // half the OR size
            float targetSize = 3 * stopSize      // 3x the stop => 1.5x the entire OR
    
        // 2) Check if price breaks above OR => go long
            if close > orHigh 
            // Only enter a new long if not already in a long position (optional)
                if strategy.position_size <= 0
                    strategy.entry("ORB Long", strategy.long)
                    strategy.exit("Long Exit", from_entry = "ORB Long", stop = orHigh - stopSize, limit  = strategy.position_avg_price + targetSize)
                // Flag that we've taken a trade today
                    tradeTakenToday := true
    
        // 3) Check if price breaks below OR => go short
            if close < orLow 
            // Only enter a new short if not already in a short position (optional)
                if strategy.position_size >= 0
                    strategy.entry("ORB Short", strategy.short)
                    strategy.exit("Short Exit", from_entry = "ORB Short", stop = orLow + stopSize, limit  = strategy.position_avg_price - targetSize)
                // Flag that we've taken a trade today
                    tradeTakenToday := true
if hour(time, "America/New_York") == 16 and minute(time, "America/New_York") == 0
    strategy.close_all()
相关推荐
更多内容