Previous Day High/Low
High and low of the previous regular trading session as horizontal levels on intraday and daily charts, with optional history.
- PDx
- Built into Spectral
- Updates every tick
- previous day
- daily high
- daily low
- support
- resistance
Updates every tick with the default settings; with "Show history" on, it updates at bar close.
MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.
Already in Spectral: add it from the Indicators toolbox. The file here is the same indicator written as a custom indicator, to change or learn from. Installed, it appears next to the built-in one, marked Custom.

Overview
Previous Day High/Low marks the highest high and the lowest low of the prior New York regular session (09:30-16:00, to 13:00 on early-close days) as two horizontal levels. The previous day is the last regular session before the date of the chart's latest bar.
How to read it
The two levels mark where the last completed session found its extremes. Traders often use them as reference areas for reaction, acceptance or rejection rather than as automatic entry signals. A break that holds tells you more than a single print through the level.
Settings and limitations
The levels come from 30-minute regular-session bars that Spectral loads beside the chart (the last week of them), so they are exact on every intraday and daily bar size, also where a chart bar holds pre-market or after-hours trading together with the session (20-minute, hourly and daily bars). Weekly and monthly charts have no previous day and show nothing.
Show history adds step lines that show, for every bar, the high and low of the session before that bar's date, and then updates at bar close. On bar sizes up to 30 minutes (other than 20 minutes) the chart's own bars line up with the 09:30 open and the close, so the history covers the whole chart; on larger bar sizes it covers only the sessions in the loaded week of 30-minute bars.
Notes
Computes the same levels as the built-in PDx in Spectral, which draws them as rays from the previous session. Pre-market and after-hours trading is never counted, and a session that is not complete in the loaded bars is not drawn. On a regular-hours chart before the open, the latest bar is still the last session's, so the levels show the session before it until the first 09:30 bar arrives; an extended-hours chart moves on with the first pre-market bar.
Settings
Each setting appears in the indicator's settings panel in Spectral, next to a color setting for every output.
| Setting | Type | Default | Range or options | What it does |
|---|---|---|---|---|
| Show history | On / off | Off | — | Also draw the previous-day high and low for every earlier day as step lines; the indicator then updates at bar close. |
What it draws
Lines
- PDH historydotted · 1 px · primary
#C4A46A - PDL historydotted · 1 px
#C4A46A
Levels
- PDHsolid · 1 px · value on the axis
#C4A46A - PDLsolid · 1 px · value on the axis
#C4A46A
Source
Save it as pdx.js and add it with Indicators → Custom indicators → Add file…. The format is explained in the custom indicators guide.
// Copyright (c) 2026 Spectral
// SPDX-License-Identifier: MIT-0
// Free to use, copy, modify and share: https://spectral.trade/docs/custom-indicators/LICENSE.txt
/** @type {import('./spectral-indicator').IndicatorV2} */
export default {
schemaVersion: 2,
id: 'pdx',
name: 'Previous Day High/Low',
shortName: 'PDx',
version: '1.1.0',
author: 'Spectral',
description: 'High and low of the previous regular trading session as horizontal levels on intraday and daily charts, with optional history.',
pane: 'price',
live: { lookback: 0, barCloseWhen: 'showHistory' },
inputs: {
showHistory: { type: 'boolean', label: 'Show history', default: false, description: 'Also draw the previous-day high and low for every earlier day as step lines; the indicator then updates at bar close.' },
},
levels: {
high: { label: 'PDH', color: '#C4A46A', showValue: true },
low: { label: 'PDL', color: '#C4A46A', showValue: true },
},
plots: {
highHistory: { label: 'PDH history', color: '#C4A46A', lineStyle: 'dotted', primary: true },
lowHistory: { label: 'PDL history', color: '#C4A46A', lineStyle: 'dotted' },
},
auxiliary: {
rth30: { barSize: '30 mins', duration: '1 W', useRth: true, keepUpToDate: true },
},
docs: {
overview: 'Previous Day High/Low marks the highest high and the lowest low of the prior New York regular session (09:30-16:00, to 13:00 on early-close days) as two horizontal levels. The previous day is the last regular session before the date of the chart\'s latest bar.',
howToRead: 'The two levels mark where the last completed session found its extremes. Traders often use them as reference areas for reaction, acceptance or rejection rather than as automatic entry signals. A break that holds tells you more than a single print through the level.',
settings: 'The levels come from 30-minute regular-session bars that Spectral loads beside the chart (the last week of them), so they are exact on every intraday and daily bar size, also where a chart bar holds pre-market or after-hours trading together with the session (20-minute, hourly and daily bars). Weekly and monthly charts have no previous day and show nothing.\n\nShow history adds step lines that show, for every bar, the high and low of the session before that bar\'s date, and then updates at bar close. On bar sizes up to 30 minutes (other than 20 minutes) the chart\'s own bars line up with the 09:30 open and the close, so the history covers the whole chart; on larger bar sizes it covers only the sessions in the loaded week of 30-minute bars.',
notes: 'Computes the same levels as the built-in PDx in Spectral, which draws them as rays from the previous session. Pre-market and after-hours trading is never counted, and a session that is not complete in the loaded bars is not drawn. On a regular-hours chart before the open, the latest bar is still the last session\'s, so the levels show the session before it until the first 09:30 bar arrives; an extended-hours chart moves on with the first pre-market bar.',
},
calculate(ctx) {
const { bars, inputs, ta, time, auxiliary, barSize } = ctx;
const none = () => bars.map(() => null);
const lastIndex = bars.length - 1;
if (lastIndex < 0 || barSize === '1 week' || barSize === '1 month') {
return { levels: { high: null, low: null }, plots: { highHistory: none(), lowHistory: none() } };
}
const widen = (range, bar) => {
if (range === null) return { high: bar.high, low: bar.low };
if (bar.high <= range.high && bar.low >= range.low) return range;
return { high: Math.max(range.high, bar.high), low: Math.min(range.low, bar.low) };
};
// The regular sessions of the 30-minute series by New York date, oldest first, each with its range, or null
// when it is not complete in the series: it starts at the 09:30 open (or an older session precedes it) and ends
// with its last 30-minute bar (or a newer session follows it).
const series = auxiliary.rth30 || [];
const sessions = [];
for (let start = 0; start < series.length;) {
const date = time.ny(series[start]).dateKey;
let end = start;
while (end + 1 < series.length && time.ny(series[end + 1]).dateKey === date) end += 1;
const last = series[end];
const startsComplete = start > 0 || time.ny(series[start]).minutes <= 9 * 60 + 30;
const endsComplete = end < series.length - 1 || !time.isRegularSession({ ...last, time: last.time + 30 * 60 });
let range = null;
for (let index = start; index <= end; index += 1) {
if (time.isRegularSession(series[index])) range = widen(range, series[index]);
}
sessions.push({ date, range: startsComplete && endsComplete ? range : null });
start = end + 1;
}
// The newest session before a date (the last regular session before it), or null when it is not complete: a
// partial session is never drawn as the full one, and an older one never in its place.
const sessionBefore = (date) => {
for (let index = sessions.length - 1; index >= 0; index -= 1) {
if (sessions[index].date < date) return sessions[index].range;
}
return null;
};
// The levels: the session before the date of the latest bar, read without carried state, so a live update needs
// only the forming bar.
const previous = sessionBefore(time.ny(bars[lastIndex]).dateKey);
const levels = { high: previous === null ? null : previous.high, low: previous === null ? null : previous.low };
if (!inputs.showHistory) return { levels, plots: { highHistory: none(), lowHistory: none() } };
// History (updates at bar close). Bars of these sizes start and end on the 09:30 open and the session close, so
// the chart's own dates and their regular-session ranges carry from bar to bar through ta.scan; larger bars can
// straddle a boundary, and their history reads the 30-minute sessions, like the levels.
const fromChart = / secs?$/.test(barSize) || ['1 min', '2 mins', '3 mins', '5 mins', '10 mins', '15 mins', '30 mins'].includes(barSize);
let ranges;
if (fromChart) {
const states = ta.scan(bars, { date: '', current: null, previous: null }, (state, bar) => {
const date = time.ny(bar).dateKey;
const fresh = date !== state.date;
const previousCurrent = fresh ? null : state.current;
const current = time.isRegularSession(bar) ? widen(previousCurrent, bar) : previousCurrent;
// A bar that changes nothing returns the state itself, which ta.scan keeps without copying it.
if (!fresh && current === state.current) return state;
return { date, current, previous: fresh ? state.current : state.previous };
});
ranges = states.map((state) => state.previous);
} else {
ranges = bars.map((bar) => sessionBefore(time.ny(bar).dateKey));
}
const history = (pick) => ranges.map((range) => (range === null ? null : range[pick]));
return { levels, plots: { highHistory: history('high'), lowHistory: history('low') } };
},
};Adapt it with an LLM
Paste this into your assistant and replace the second-to-last line with the change you want.
Start from this Spectral custom indicator: https://spectral.trade/indicators/pdx.js Format reference: https://spectral.trade/docs/custom-indicators.llm.md Keep the file format and every rule of the reference; give the result a new id, name, shortName and version, and update docs and input descriptions to match. Keep its live updates exact and fast (section "Fast live updates" of the reference): carry values from bar to bar only through ctx.ta, and raise live.lookback if the change reads further back; Spectral rejects a file whose live updates differ from a full recalculation or are too slow. Change I want: <describe the change> Answer with the complete file in one code block, ready to save as <id>.js.


