OPEN-SOURCE SCRIPT

TE Previous Session Structure Week Levels Lifecycle State

560
TE Previous Session Structure plots key completed reference levels from the prior trading day, prior regular session, overnight session and prior week, then tracks what price has already done at those levels.

The core question is simple:

Which prior references matter now, and what has price already done to them?

The indicator maintains eleven completed-period references:

PDH, PDL, PDC — previous trading day high, low and close
RTHH, RTHL, RTHC — previous regular session high, low and close
ONH, ONL — overnight high and low
PWH, PWL, PWC — previous week high, low and close

Visual example:
syot kilat

SESSION STRUCTURE

The trading day is not treated as the calendar day. It follows the exchange's own trading-day boundary, so a futures session that opens the prior evening is still treated as one trading day.

The regular session comes from the exchange's own session definition rather than a manually entered UTC offset.

RTHC is deliberately labeled as the regular-session CLOSE, not settlement. The official exchange settlement can differ from the final session print, so the script does not present a value it cannot actually obtain from the chart.

LIFECYCLE STATES

Every level carries a state describing what price has already done to it:

SET
BROKEN ABOVE
BROKEN BELOW
RECLAIMED
EXPIRED

When a level is first published, the indicator records which side of the level price is on:

side₀ = sign(close - level)

All later lifecycle changes are evaluated relative to that original side.

This means a previous-day low that begins below price is considered broken when price later closes below it and reclaimed when price closes back above it. A high works in the opposite direction.

Visual example:
syot kilat

A WICK IS A TOUCH, NOT A BREAK

One of the most important rules in the indicator is that a break requires a confirmed close beyond the level.

If price trades through a level intrabar but closes back on the original side, the level remains unbroken.

That interaction is recorded as a touch instead.

Touches count closed bars whose full high-low range contained the level, including a bar that later produces a valid close-through break.

This prevents temporary intrabar excursions from creating false lifecycle changes.

Visual example:
syot kilat

RECLAIMS AND RETIREMENT

After a level is broken, a confirmed close back on its original side changes the state to RECLAIMED.

A level may move through several legitimate transitions over its life:

SET → BROKEN → RECLAIMED → BROKEN again

Each transition requires its own confirmed close.

The indicator can also retire structure that price has moved away from.

If a level remains broken for N consecutive confirmed bars without being reclaimed, it becomes EXPIRED.

The counter resets immediately on a reclaim.

Default:

N = 0

This keeps levels indefinitely unless the user chooses a retirement period.

Expired levels can either disappear or remain visible in a muted style.

Visual example:
syot kilat

READOUT

The indicator also maintains a table of the live levels nearest to current price.

For each level it can show:

Level key
Lifecycle state
Distance from current price

The table is ordered by absolute distance only. It does not assign an importance, strength or probability score.

Color and line style identify the source group — trading day, regular session, overnight or week — rather than bullish or bearish direction.

WHAT IT DOES NOT DO

It does not predict price direction.

It does not rank levels by strength or importance.

It does not claim that a level will hold.

It does not generate entries, stops or targets.

SET, BROKEN, RECLAIMED and EXPIRED describe historical interaction with a reference level. They are observations, not forecasts.

All lifecycle transitions are evaluated on confirmed bars. The script also uses zero request.security() calls.

TE Previous Session Structure is designed to turn a static prior-level map into a structured record of what price has actually done at those references.

Trader's Edge

Financial Disclaimer: For educational and informational purposes only. Nothing in this indicator constitutes financial, investment or trading advice, or a recommendation to buy, sell or hold any instrument. Market trading involves risk, and past price behavior does not predict future results.

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.