OPEN-SOURCE SCRIPT
IB Completed

IB Completed — Initial Balance Breakout & Retest Strategy
═══════════════════════════════════════════════════════════════
OVERVIEW
IB Completed is a fully automated intraday strategy that trades the Initial Balance (IB) breakout-and-retest pattern. Rather than entering on the initial breakout, it waits for a confirmed pullback to the IB level before entering — filtering out false breakouts and aligning entries with proven support/resistance.
Designed for futures (MES, ES, NQ, MNQ, GC, etc.) on 1-min through 15-min charts, but works on any liquid instrument with a defined opening session.
═══════════════════════════════════════════════════════════════
HOW IT WORKS
Build the IB — During a configurable window (default 9:30–10:30 ET), the high and low are recorded and locked in for the day.
Breakout — Price breaks above IB High (long) or below IB Low (short).
Retest — Price pulls back to the IB level while closing on the opposite side of the trigger SMA, confirming the pullback.
Reclaim & Entry — Price closes back beyond the IB level AND the trigger SMA, confirming the retest held. Entry fires at the bar close.
Only one trade per session is allowed.
Stop Placement: Placed at the most recent confirmed pivot (swing high/low) from the retest phase, offset by a configurable amount. Falls back to the retest extreme if no pivot exists.
Scaled Exits: Position is split across up to 5 R-multiple targets (default: 50% at 1R, 25% at 2R, 25% at 3R). Configurable as percentages or fixed contract quantities.
Break-Even Stop: After a configurable R-multiple is reached (default 2R), the stop moves to entry price.
EOD Flatten: All positions force-closed at a set time (default 3:55 PM ET).
═══════════════════════════════════════════════════════════════
INPUTS
Opening Range Window — Start/end hour and minute for the IB session, plus timezone selection (New York, Chicago, LA, London, Tokyo, Singapore, Sydney).
Pivot Settings — Left and right bar counts for pivot detection (stop-loss reference).
Trigger SMA — Length, source, visibility, and color for the SMA that governs retest/reclaim signals.
Higher Timeframe Filter — Optional trend filter using a higher-timeframe MA (SMA/EMA/WMA/VWMA). Longs require close > HTF MA, shorts require close < HTF MA. Configurable timeframe and length.
Risk / Stop Loss — Stop offset mode (Points or Percentage), offset amount, and optional setup invalidation if price breaches the opposite IB level.
Position Sizing — Fixed contracts or Risk-Based sizing (set a dollar risk amount and tick value; contracts are calculated so stop distance equals that risk).
Exit Scaling (R-Multiples) — Configure exit percentages or contract quantities at 1R through 5R.
Break-Even Stop — Enable/disable, and set the R-multiple trigger.
Session & Risk — Trade cutoff time, go-flat time, and toggles to enable/disable longs and shorts independently.
IB Size Filter — Optionally block trades when the IB range exceeds a max tick threshold.
Day-of-Week Filter — Checkboxes to skip any day of the week (e.g., skip Thursdays).
Location / Trend Filters — 17 optional filters, all OFF by default. Each can be shown on chart and/or used as an entry gate (longs require close above, shorts require close below). Includes: Previous Week H/L, Previous Day H/L, Magic Lines (pre-market H/L), Overnight Low, Daily 9 SMA, 4H 9 SMA, and 100/200 SMA on Weekly, Daily, 4H, and 1H timeframes.
Display — IB line colors, styles, box settings, trade level line length, IB 25/50/75% interior lines, and fully customizable entry/stop/target colors for both long and short sides.
Info Panel — Floating panel showing IB stats (high, low, range, ticks, bias, close zone), setup status, position, BE stop, HTF MA, and filter status. Configurable text size.
═══════════════════════════════════════════════════════════════
ALERTS
JSON-formatted alert messages fire on every entry and exit, ready for webhook automation. Fields include side, ticker, quantity, entry, stop, and R-level. Three alertconditions are also available: IB Complete, Long Entry, and Short Entry.
═══════════════════════════════════════════════════════════════
OVERVIEW
IB Completed is a fully automated intraday strategy that trades the Initial Balance (IB) breakout-and-retest pattern. Rather than entering on the initial breakout, it waits for a confirmed pullback to the IB level before entering — filtering out false breakouts and aligning entries with proven support/resistance.
Designed for futures (MES, ES, NQ, MNQ, GC, etc.) on 1-min through 15-min charts, but works on any liquid instrument with a defined opening session.
═══════════════════════════════════════════════════════════════
HOW IT WORKS
Build the IB — During a configurable window (default 9:30–10:30 ET), the high and low are recorded and locked in for the day.
Breakout — Price breaks above IB High (long) or below IB Low (short).
Retest — Price pulls back to the IB level while closing on the opposite side of the trigger SMA, confirming the pullback.
Reclaim & Entry — Price closes back beyond the IB level AND the trigger SMA, confirming the retest held. Entry fires at the bar close.
Only one trade per session is allowed.
Stop Placement: Placed at the most recent confirmed pivot (swing high/low) from the retest phase, offset by a configurable amount. Falls back to the retest extreme if no pivot exists.
Scaled Exits: Position is split across up to 5 R-multiple targets (default: 50% at 1R, 25% at 2R, 25% at 3R). Configurable as percentages or fixed contract quantities.
Break-Even Stop: After a configurable R-multiple is reached (default 2R), the stop moves to entry price.
EOD Flatten: All positions force-closed at a set time (default 3:55 PM ET).
═══════════════════════════════════════════════════════════════
INPUTS
Opening Range Window — Start/end hour and minute for the IB session, plus timezone selection (New York, Chicago, LA, London, Tokyo, Singapore, Sydney).
Pivot Settings — Left and right bar counts for pivot detection (stop-loss reference).
Trigger SMA — Length, source, visibility, and color for the SMA that governs retest/reclaim signals.
Higher Timeframe Filter — Optional trend filter using a higher-timeframe MA (SMA/EMA/WMA/VWMA). Longs require close > HTF MA, shorts require close < HTF MA. Configurable timeframe and length.
Risk / Stop Loss — Stop offset mode (Points or Percentage), offset amount, and optional setup invalidation if price breaches the opposite IB level.
Position Sizing — Fixed contracts or Risk-Based sizing (set a dollar risk amount and tick value; contracts are calculated so stop distance equals that risk).
Exit Scaling (R-Multiples) — Configure exit percentages or contract quantities at 1R through 5R.
Break-Even Stop — Enable/disable, and set the R-multiple trigger.
Session & Risk — Trade cutoff time, go-flat time, and toggles to enable/disable longs and shorts independently.
IB Size Filter — Optionally block trades when the IB range exceeds a max tick threshold.
Day-of-Week Filter — Checkboxes to skip any day of the week (e.g., skip Thursdays).
Location / Trend Filters — 17 optional filters, all OFF by default. Each can be shown on chart and/or used as an entry gate (longs require close above, shorts require close below). Includes: Previous Week H/L, Previous Day H/L, Magic Lines (pre-market H/L), Overnight Low, Daily 9 SMA, 4H 9 SMA, and 100/200 SMA on Weekly, Daily, 4H, and 1H timeframes.
Display — IB line colors, styles, box settings, trade level line length, IB 25/50/75% interior lines, and fully customizable entry/stop/target colors for both long and short sides.
Info Panel — Floating panel showing IB stats (high, low, range, ticks, bias, close zone), setup status, position, BE stop, HTF MA, and filter status. Configurable text size.
═══════════════════════════════════════════════════════════════
ALERTS
JSON-formatted alert messages fire on every entry and exit, ready for webhook automation. Fields include side, ticker, quantity, entry, stop, and R-level. Three alertconditions are also available: IB Complete, Long Entry, and Short Entry.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.