Williams Inside Day Breakout Strategy

INSIDE DAY BREAKOUT STOP LOSS FPO
Created on: 2025-10-11 16:55:28 Modified on: 2025-10-11 16:55:28
Copy: 0 Number of hits: 212
avatar of ianzeng123 ianzeng123
2
Follow
319
Followers

 Williams Inside Day Breakout Strategy  Williams Inside Day Breakout Strategy

🎯 What’s This Strategy Really About?

You know what? This strategy is like playing β€œhide and seek” in the stock market! πŸ“ˆ When the market shows an β€œinside day” (today’s range is completely contained within yesterday’s), it’s like the market is holding its breath, preparing for a big explosion!

Key point! This strategy specifically captures those β€œcan’t hold it anymore” breakout moments, especially on the β€œgolden trading days” of Monday, Thursday, and Friday.

πŸ” The Core Logic is Super Simple

Imagine the market as a compressed spring: - Yesterday was an β€œinside day” (completely contained within the day before) - The day before yesterday was a big bullish candle (bulls were excited) - Today’s opening price must be below key resistance levels

When price breaks above the highest point of the past 3 periods, it’s like releasing a compressed spring - the strategy immediately goes long! πŸš€

πŸ’‘ Risk Control: Two Safety Locks

First Lock: Fixed Stop Loss You can choose point-based or percentage-based stop loss, like setting a β€œloss limit” for yourself - never be greedy!

Second Lock: FPO Exit Rule This is the smartest part! Once any day opens with profit, immediately take profits. It’s like the wisdom of β€œquit while you’re ahead” - don’t wait for the market to change its mind! ✨

πŸŽͺ Why Choose Specific Trading Days?

The strategy only trades on Monday, Thursday, and Friday - this isn’t random! These days are typically: - Monday: Direction setting for the new week - Thursday: Important data release day
- Friday: Fund rebalancing day

Avoid the β€œbland days” of Tuesday and Wednesday, only strike when there’s a story to tell!

🌟 Who Is This Strategy For?

If you’re the type of trader who likes β€œquick in, quick out” and doesn’t want to watch screens all day, this strategy is tailor-made for you! It has clear entry signals, clean stop-loss rules, and smart profit-taking mechanisms.

Remember: The market is like a spring - the tighter it’s compressed, the higher it bounces! 🎯

Strategy source code
/*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)