OPEN-SOURCE SCRIPT

Anchor rails - session levels and event countdown [AuraSznfx]

574
Most intraday trading is organized around a handful of scheduled clock times — the London open, the 8:30 and 10:00 data releases, the cash open, the end of the first hour, the 2:00 policy release. This script makes that schedule visible on the chart instead of tracked in your head, and pairs it with the price levels that formed before each one.

There are many scripts that draw session highs and lows. What this one adds is the clock layer on top of them: a countdown to the next scheduled anchor, a phase read-out describing where the current bar sits relative to that anchor, a configurable window marked either side of it, and a running count of how many of the day's tracked levels have already been taken.


WHAT IT DRAWS

Five session ranges: overnight, London, premarket, opening range, and first hour. Each window's start and end time is a session input you can change, so the defaults are a starting point rather than a rule. While a window is open the script tracks its running high and low and shows them as a box. When the window closes, the box is deleted and replaced by two horizontal lines fixed at the final high and low, extended forward a configurable number of bars.

Yesterday's high, low and close, pulled from the daily timeframe with lookahead disabled. An optional midpoint is available.


HOW THE LEVEL-TAKEN LOGIC WORKS

Once a range is locked, each of its two lines is watched independently. The high is marked taken the first time a bar's high exceeds it. The low is marked taken the first time a bar's low falls below it. Detection is one-way and permanent for the session — a level does not un-take itself if price returns.

When a level is taken you can have it dim to a configurable transparency, dim and switch its label to a marked state, or delete outright. That choice is a style preference; the underlying state is tracked the same way regardless.

Note the deliberate limitation: detection uses the bar's high and low, so on a live bar a level can register as taken and then the bar can close back inside the range. If you want confirmed-close behavior instead, use a higher timeframe or wait for the bar to close before acting on the alert.


HOW THE ANCHOR CLOCK WORKS

You enable whichever of the nine preset times you care about, plus one custom hour and minute of your own. Every one is read in the timezone you select at the top of the settings.

On each bar the script builds a timestamp for every enabled anchor on the current date, then finds the nearest one ahead of the current bar close and the nearest one behind it. From those two distances it produces four outputs in the panel:

Time to the next anchor, formatted as a countdown.

A progress bar filling over the final 30 minutes before it.

A phase label, resolved in this priority order: inside the post-anchor window, within 15 minutes after, inside the pre-anchor window, inside 10 minutes, inside 30 minutes, otherwise standby.

A taken count out of the ten tracked level lines.

If every enabled anchor for the day has passed, the countdown rolls to the earliest one on the following day.

The event window is the pre and post minute values you set. When the current bar falls inside it, the chart is optionally tinted, and an alert can fire once as it begins. Nothing about this window predicts direction. It marks that a scheduled release is close, which is information you would otherwise be checking a calendar for.


HOW TO USE IT

Set your timezone first; everything else reads from it. Adjust the five session windows to the instrument you trade — the defaults are built around US index futures on New York time and will not suit an FX or crypto session structure without changes. Then switch off the anchor times that aren't relevant to your market.

The levels show where price has already been tested. The clock shows when the next scheduled event arrives. What you do with either is your decision — this script issues no buy or sell signals and takes no view on direction.


ALERTS

Two alert condition entries are provided, for any level taken and for the event window opening, usable from the standard alert dialog. Individual per-level alerts fire through the alert() function on bar close. Payloads can be sent as plain text or as structured JSON for webhook use, toggled in the settings.


NOTES AND LIMITATIONS

Written in Pine v6.

Locked levels do not repaint. A range only becomes lines after its window has closed, and those values never change afterward.

The daily request uses lookahead_off. No future data is accessed anywhere in the script.

The phase labels describe clock position only. They are not signals and carry no expectation of what price will do.

The script has no view on direction and produces no entry or exit signals. It is a context tool.

On very low timeframes the drawing limits of 500 lines, boxes and labels can be reached over a long history. Reduce the extend-right value or switch off sessions you do not need.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.