OPEN-SOURCE SCRIPT
已更新 Weekly Initial Balance

This indicator marks the Weekly Initial Balance — the price range established during the first two trading days of the week — and projects extension levels for the remainder of the week.
The idea behind it
Monday sets the opening range for the week. Tuesday may extend that range — it could produce a false break, a range extension, a reversal, or an inside day. In a large majority of weeks, by the time Monday and Tuesday have traded, the high and low extremes are already in place for the rest of the week. One of these extremes will tend to hold, while the other may get broken.
The default window (Sunday 18:00 – Tuesday 16:00 New York time) captures exactly this: the full Monday session plus Tuesday's contribution. Once the IB window closes, the remaining days of the week tend to trade in relation to these established levels.
What makes this different
Most Initial Balance indicators focus on the first 30 or 60 minutes of a single session. This indicator applies the IB concept to the weekly timeframe — capturing the Mon-Tue range that statistically defines the week's extremes. The configurable window, range extension multipliers, and clean label handling (current week only) make it a practical tool rather than a theoretical overlay.
How it works
- A shaded box marks the IB range (high and low) as it forms during the configured window
- After the window closes, the IB high, low, and 50% midpoint extend as horizontal reference levels
- Configurable range extensions (default 0.5x and 1.0x of the IB range) project above and below as potential targets
- Price labels display the exact level at each line (current week only — historical weeks show clean lines without clutter)
How to use it
- **Which side holds?** After the IB window closes, one extreme tends to hold for the week while the other gets broken — watch for which side price tests and rejects first
- **Range extensions as targets:** When the IB high or low breaks, the 0.5x and 1.0x extensions provide measured-move targets
- **Inside weeks:** If price stays within the IB range through Friday, the 50% midpoint often acts as a magnet
- **Volatility read:** A wide Monday–Tuesday range suggests the week's extremes may already be set; a narrow range suggests expansion is still ahead
- **Alerts:** Built-in alerts fire when price breaks the IB high or low after the window closes
Settings
- Fully configurable start/end day, hour, and minute (New York time)
- Adjustable number of historical weeks to display
- Configurable extension multipliers (not limited to 0.5x and 1.0x)
- Toggle individual levels, labels, and extensions on/off
- Works on any instrument with sufficient intraweek data (futures, forex, crypto)
Recommended timeframes: 30min and 1H charts for best visual clarity. Intraday only — the indicator requires sufficient chart history to display the configured number of weeks.
The idea behind it
Monday sets the opening range for the week. Tuesday may extend that range — it could produce a false break, a range extension, a reversal, or an inside day. In a large majority of weeks, by the time Monday and Tuesday have traded, the high and low extremes are already in place for the rest of the week. One of these extremes will tend to hold, while the other may get broken.
The default window (Sunday 18:00 – Tuesday 16:00 New York time) captures exactly this: the full Monday session plus Tuesday's contribution. Once the IB window closes, the remaining days of the week tend to trade in relation to these established levels.
What makes this different
Most Initial Balance indicators focus on the first 30 or 60 minutes of a single session. This indicator applies the IB concept to the weekly timeframe — capturing the Mon-Tue range that statistically defines the week's extremes. The configurable window, range extension multipliers, and clean label handling (current week only) make it a practical tool rather than a theoretical overlay.
How it works
- A shaded box marks the IB range (high and low) as it forms during the configured window
- After the window closes, the IB high, low, and 50% midpoint extend as horizontal reference levels
- Configurable range extensions (default 0.5x and 1.0x of the IB range) project above and below as potential targets
- Price labels display the exact level at each line (current week only — historical weeks show clean lines without clutter)
How to use it
- **Which side holds?** After the IB window closes, one extreme tends to hold for the week while the other gets broken — watch for which side price tests and rejects first
- **Range extensions as targets:** When the IB high or low breaks, the 0.5x and 1.0x extensions provide measured-move targets
- **Inside weeks:** If price stays within the IB range through Friday, the 50% midpoint often acts as a magnet
- **Volatility read:** A wide Monday–Tuesday range suggests the week's extremes may already be set; a narrow range suggests expansion is still ahead
- **Alerts:** Built-in alerts fire when price breaks the IB high or low after the window closes
Settings
- Fully configurable start/end day, hour, and minute (New York time)
- Adjustable number of historical weeks to display
- Configurable extension multipliers (not limited to 0.5x and 1.0x)
- Toggle individual levels, labels, and extensions on/off
- Works on any instrument with sufficient intraweek data (futures, forex, crypto)
Recommended timeframes: 30min and 1H charts for best visual clarity. Intraday only — the indicator requires sufficient chart history to display the configured number of weeks.
版本注释
Weekly Initial Balance — v1.1 Update New:
- 25% / 75% quartile levels (toggleable, customizable color/style/width) — pullback and entry reference zones inside the
IB range
Improvements:
- Toggles now hide lines instantly (previously stale lines could linger until aged out) - Extension lines now begin exactly at the last window bar (removed the 1-bar visual gap)
- Timeframe guard tightened to 2H and below (4H+ bars can straddle Sun 6PM / Tue 4PM boundaries and produce imprecise
levels)
- Labels update in place instead of being recreated each tick (smoother realtime rendering) - Stale-state safety net added to protect against data gaps at window start
Code quality:
- Explicit day mapping (clearer intent, no reliance on numeric day constants)
- Cleaner break detection logic
版本注释
**Update — robustness & customization**This update makes every visual toggle work retroactively across current and historical weeks, adds a third configurable range extension, and fixes two edge cases (mid-window chart loads and silent line-cap overruns).
**What's new**
- Third range extension (1.5x default), fully configurable like the others
- Style and width customization for all extension lines (matching the quartile controls)
- Configurable label offset — clean spacing between line endpoints and price labels
- "Weeks to Show" max set to 20 (line-cap-safe with all features enabled)
**What's improved**
- Toggling any feature on/off (50% level, quartiles, extensions, post-window levels) now applies instantly to current AND historical weeks — no more "toggle only affects future weeks"
- Charts that load mid-window no longer initialize a partial IB from an arbitrary bar
- Reducing "Weeks to Show" trims old drawings immediately instead of waiting for the next IB window
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
Access my indicators and manual at: constantinpabst.com/
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
Access my indicators and manual at: constantinpabst.com/
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。