威廉姆斯内包日突破策略

INSIDE DAY BREAKOUT STOP LOSS FPO
创建日期: 2025-10-11 16:55:28 最后修改: 2025-10-11 16:55:28
复制: 0 点击次数: 212
avatar of ianzeng123 ianzeng123
2
关注
319
关注者

威廉姆斯内包日突破策略 威廉姆斯内包日突破策略

🎯 这个策略到底在玩什么?

你知道吗?这个策略就像是在股市里玩”躲猫猫”游戏!📈 当市场出现”内包日”(就是今天的波动完全被昨天包住),就像是市场在憋大招,准备来个大爆发!

划重点!这个策略专门捕捉那些”憋不住”的突破时刻,特别是在周一、周四、周五这些”黄金交易日”出手。

🔍 策略的核心逻辑超简单

想象一下,市场就像一个被压缩的弹簧: - 昨天是个”内包日”(完全被前天包住) - 前天还是个大阳线(多头很兴奋) - 今天开盘价要低于关键阻力位

当价格突破过去3个周期的最高点时,就像弹簧被释放一样,策略立刻入场做多!🚀

💡 风险控制:两道保险锁

第一道锁:固定止损 可以选择点数止损或百分比止损,就像给自己设个”亏损上限”,绝不贪心!

第二道锁:FPO退出法则 这是最聪明的地方!一旦某天开盘就盈利了,立刻获利了结。这就像”见好就收”的智慧,不等市场反悔!✨

🎪 为什么选择特定交易日?

策略只在周一、周四、周五交易,这可不是随便选的!这些日子通常是: - 周一:新一周的方向确立 - 周四:重要数据发布日 - 周五:资金调仓日

避开周二周三这些”平淡日”,专挑有故事的日子出手!

🌟 这个策略适合谁?

如果你是那种喜欢”快进快出”、不想整天盯盘的交易者,这个策略简直是为你量身定制的!它有明确的入场信号、清晰的止损规则,还有聪明的获利退出机制。

记住:市场就像弹簧,压得越紧,弹得越高!🎯

策略源码
/*backtest
start: 2025-01-01 00:00:00
end: 2025-10-09 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BNB_USDT","balance":500000}]
*/

//@version=5
strategy("Larry Williams Bonus Track Pattern", overlay=true)

//──────────────────────────────────
// Inputs
//──────────────────────────────────
useDayFilter = input.bool(true, "Trade only Mon/Thu/Fri")
sl_type      = input.string("Points", "Stop Loss Type", options=["Points","Percent"])
sl_value     = input.float(1.0, "Stop Loss Value (points or %)", step=0.1, minval=0.0)
debugPlot    = input.bool(false, "Show Levels")

//──────────────────────────────────
// DAILY SERIES for SIGNAL
//──────────────────────────────────
hD = request.security(syminfo.tickerid, "D", high,  lookahead=barmerge.lookahead_off)
lD = request.security(syminfo.tickerid, "D", low,   lookahead=barmerge.lookahead_off)
oD = request.security(syminfo.tickerid, "D", open,  lookahead=barmerge.lookahead_off)
cD = request.security(syminfo.tickerid, "D", close, lookahead=barmerge.lookahead_off)

// Inside bar (yesterday) and prior bar (two days ago) is bullish
inside_prev         = hD[1] < hD[2] and lD[1] > lD[2]
prev_of_inside_bull = cD[2] > oD[2]

// Relevant highs: inside (t-1) + two prior bars (t-2, t-3)
inside_high        = hD[1]
max_pre_inside_two = math.max(hD[2], hD[3])
entry_stop_price   = math.max(inside_high, max_pre_inside_two)   // highest of the last 3 bars

//──────────────────────────────────
// DAILY LOGIC (first bar of the day)
//──────────────────────────────────
isNewDay = ta.change(time("D"))     // true on the FIRST bar of each day
dayOpen  = open                      // real daily open
dow      = dayofweek                 // day of week (works intraday)

passDay  = not useDayFilter or (dow == dayofweek.monday or dow == dayofweek.thursday or dow == dayofweek.friday)
open_ok  = dayOpen < inside_high and dayOpen < max_pre_inside_two

// Valid setup ONLY for the day immediately after the inside bar
longSetupToday = isNewDay and passDay and inside_prev and prev_of_inside_bull and open_ok

//──────────────────────────────────
// Helper function to create a “day identifier” as a numeric value
//──────────────────────────────────
getDayId() =>
    year(time) * 10000 + month(time) * 100 + dayofmonth(time)

//──────────────────────────────────
// Pending order management / exact entry the day after inside bar
//──────────────────────────────────
var float entryPrice = na
var int entryDayId = na

if isNewDay
    // Cancel any pending stop from the previous day (TIF: 1 day)
    strategy.cancel("LE")

    // If today is the next day after inside and open is valid:
    if longSetupToday and strategy.position_size == 0
        if dayOpen >= entry_stop_price
            // Gap above stop → enter at MARKET on today’s open
            strategy.entry("LE", strategy.long)
        else
            // No gap → place a STOP valid only for today
            strategy.entry("LE", strategy.long, stop=entry_stop_price)

// Record the entry day when position opens
enteredNow = strategy.position_size > 0 and strategy.position_size[1] == 0
if enteredNow
    entryPrice := strategy.position_avg_price
    entryDayId := getDayId()

//──────────────────────────────────
// Fixed Stop Loss
//──────────────────────────────────
if strategy.position_size > 0
    avg = strategy.position_avg_price
    sl_price = sl_type == "Points" ? (avg - sl_value) : (avg * (1.0 - sl_value/100.0))
    strategy.exit(id="SL", from_entry="LE", stop=sl_price)
else
    strategy.cancel("SL")

//──────────────────────────────────
// FPO: Close on the FIRST profitable open AFTER entry day
// (never on the same day)
//──────────────────────────────────
if isNewDay and strategy.position_size > 0 and not na(entryDayId)
    if getDayId() > entryDayId and dayOpen > strategy.position_avg_price
        strategy.close("LE", comment="FPO")

//──────────────────────────────────
// Optional Plots
//──────────────────────────────────
plot(debugPlot ? inside_high        : na, "Inside High (D-1)")
plot(debugPlot ? max_pre_inside_two : na, "High (D-2/D-3)")
plot(debugPlot ? entry_stop_price   : na, "Entry (max of last 3 highs)", linewidth=2)
相关推荐