ta.highest#
Highest value over the trailing length bars ending at i.
SYNTAX#
function ta.highest(values: (number | null)[], length: number, i: number): number | nullARGUMENTS#
values((number | null)[]) — Series of input values.length(number) — Window length. Must be positive.i(number) — Current bar index.
RETURNS#
number | null — maximum over the window.
REMARKS#
Pair with ta.lowest on the same window to build Donchian channels or breakout signals.
EXAMPLE#
const high = [], low = [];
function onBar(i, ctx) {
high[i] = candles[i].high;
low[i] = candles[i].low;
const top = ta.highest(high, 20, i);
const bot = ta.lowest(low, 20, i);
if (top !== null) plot('donchUp', top, { color: '#26a69a' });
if (bot !== null) plot('donchDn', bot, { color: '#ef5350' });
}