Bars Into Session¶
Indicators · Levels
Bars elapsed since the current session opened (0 on the open bar, then 1, 2, …). NaN outside the session. The timer behind opening-range logic ('trade only in the first 6 bars of the London session').
Bars Into Session counts how many bars have elapsed since the current session opened — 0 on the opening bar, 1 on the next, and so on — and reads NaN outside the session. It's the timer behind opening-range and time-of-session logic: "only trade the first few bars," "avoid the open," "act mid-session."
How it works¶
From the bars input it finds the current session's first bar (for the selected session) and counts bars from there, resetting to 0 each new session. Outside the chosen session there's no count, so it emits NaN. Session boundaries use the session's own exchange timezone. Lookahead-free.
When to use it¶
Use it as a within-session clock to shape when a rule can act: gate entries to the first N bars for opening-range plays, skip the first few bars to dodge open volatility, or restrict a rule to a mid-session window. Compare the count to a Constant with LessThan / GreaterThan to build the window.
Example¶
Opening-range window: wire bars into Bars Into Session (session = London), require the count < 6 with LessThan, and And it with a breakout trigger so entries only fire in the first six bars of the session. Backtest in the Tester.
Tips & gotchas¶
- 0 on the open bar, then increments — mind the off-by-one when thresholding.
- NaN outside the session — downstream reads that as "no value," so gates naturally go quiet.
- Pairs with Opening Range and New Session for full session logic.
Related blocks¶
Inputs¶
| Socket | Type | What to wire in |
|---|---|---|
| Bars | bars |
Price bars. |
Outputs¶
| Output | Type | Plots as | Description |
|---|---|---|---|
| bars | series |
Line · sub-pane | Bars since the session open (NaN when out of session). |
Parameters¶
| Parameter | Type | Default | What it does |
|---|---|---|---|
| Session | choice (asia, london, newyork, day) |
london |
Reference auto-generated from the block catalog · category Indicators.