> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hyperprop.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Examples

> Complete Hyperprop Script indicators you can paste into the script editor and run.

Paste any of these into **Indicators → My scripts → Create script**. The pane
type to choose is noted for each one.

## Daily ATR on a 1-minute chart

**Overlay.** Yesterday's high and low as dashed lines, with yesterday's daily
ATR in a centered table. Values come from closed daily bars only, so history
doesn't repaint.

```js theme={null}
const length = input.int('ATR length', 14, { min: 1, max: 100 });
const daily  = request.bars('1D');

function compute(bars, inputs, hp) {
  if (daily.status !== 'ready') return { plots: [] };
  const atr = daily.align(hp.atr(daily.bars, length));
  const last = bars.length - 1;
  return {
    plots: [
      { title: 'PDH', values: daily.high, color: '#26a69a', style: 'dashed' },
      { title: 'PDL', values: daily.low,  color: '#ef5350', style: 'dashed' },
    ],
    tables: [{ align: 'center', cells: [
      ['Daily ATR', { text: atr[last]?.toFixed(2) ?? '–', align: 'right' }],
    ] }],
  };
}
```

## Centered table

**Overlay.** A centered info table in the middle of the top edge.

```js theme={null}
function compute(bars, inputs, hp, chart) {
  const last = bars.length - 1;
  const atr = hp.atr(bars, 14);
  return {
    plots: [],
    tables: [{
      position: 'top-center',
      align: 'center',
      size: 12,
      bg: 'rgba(20,20,20,0.8)',
      cells: [
        [{ text: chart.symbol ?? '', color: '#f59e0b' }, chart.timeframe ?? ''],
        ['Last', bars[last]?.c.toFixed(2) ?? '–'],
        ['ATR 14', atr[last]?.toFixed(2) ?? '–'],
      ],
    }],
  };
}
```

## RSI oscillator

**Separate pane.** A fixed 0 to 100 scale with 30 and 70 guides.

```js theme={null}
const length = input.int('Length', 14, { min: 2, max: 100 });

function compute(bars, inputs, hp) {
  const rsi = hp.rsi(bars.map(b => b.c), length);
  return {
    plots: [{ title: 'RSI', values: rsi, color: '#ab47bc' }],
    range: { min: 0, max: 100 },
    guides: [30, 70],
  };
}
```

## Supply and demand zones

**Overlay.** Build each zone's lifecycle (created, then mitigated), and draw
only zones still alive at the last bar. The boxes extend into the future.

```js theme={null}
const lookback = input.int('Lookback (bars)', 10, { min: 3, max: 50 });

function compute(bars, inputs, hp) {
  const highs = bars.map(b => b.h), lows = bars.map(b => b.l);
  const ph = hp.pivothigh(highs, lookback), pl = hp.pivotlow(lows, lookback);
  const boxes = [], last = bars.length - 1;
  for (let p = 0; p < bars.length; p += 1) {
    if (pl[p] == null && ph[p] == null) continue;
    const bull = pl[p] != null;
    const top = highs[p], bottom = lows[p];
    let mitigated = false;
    for (let j = p + lookback; j <= last; j += 1) {
      if (bull ? lows[j] < bottom : highs[j] > top) { mitigated = true; break; }
    }
    if (mitigated) continue;
    boxes.push({
      x1: p, y1: top, x2: last + 20, y2: bottom,
      bg: bull ? 'rgba(0,200,83,0.18)' : 'rgba(211,47,47,0.18)',
      border: bull ? '#00c853' : '#d32f2f',
      text: bull ? 'demand' : 'supply',
    });
  }
  return { plots: [], boxes };
}
```

## Signal engine

**Overlay.** Pine keeps `var` state across bars. In Hyperprop Script, replay
the state machine in one loop. This example takes one signal at a time on an
EMA crossover, with a stop below the signal bar and a 2R target, and shows
finished signals as faded markers.

```js theme={null}
const fastLen = input.int('Fast EMA', 9, { min: 1 });
const slowLen = input.int('Slow EMA', 21, { min: 1 });

function compute(bars, inputs, hp, chart) {
  const closes = bars.map(b => b.c);
  const up = hp.crossover(hp.ema(closes, fastLen), hp.ema(closes, slowLen));
  const pad = 4 * (chart.tickSize ?? 0.25);
  let active = null;
  const done = [];
  for (let i = 1; i < bars.length; i += 1) {
    if (active) {
      if (bars[i].l <= active.sl || bars[i].h >= active.tp) {
        done.push({ ...active, win: bars[i].h >= active.tp });
        active = null;
      }
    }
    if (!active && up[i]) {
      const entry = closes[i], sl = bars[i].l - pad;
      active = { bar: i, entry, sl, tp: entry + (entry - sl) * 2 };
    }
  }
  const markers = done.slice(-200).map(s => ({
    x: s.bar, y: 'below', shape: 'triangle-up',
    color: s.win ? 'rgba(38,166,154,0.5)' : 'rgba(239,83,80,0.5)',
  }));
  const lines = [], labels = [];
  if (active) {
    const end = bars.length + 20;
    lines.push(
      { x1: active.bar, y1: active.entry, x2: end, y2: active.entry, color: '#90a4ae', style: 'dashed' },
      { x1: active.bar, y1: active.sl, x2: end, y2: active.sl, color: '#ef5350' },
      { x1: active.bar, y1: active.tp, x2: end, y2: active.tp, color: '#26a69a' },
    );
    labels.push(
      { x: end, y: active.sl, text: 'SL', anchor: 'right', color: '#ef5350' },
      { x: end, y: active.tp, text: 'TP', anchor: 'right', color: '#26a69a' },
    );
    markers.push({ x: active.bar, y: 'below', shape: 'triangle-up', color: '#26a69a' });
  }
  return { plots: [], markers, lines, labels };
}
```

## New York session shading

**Overlay.** `Intl.DateTimeFormat` handles the time zone. Only recent history
is shaded to stay well under the background band cap.

```js theme={null}
const fmt = new Intl.DateTimeFormat('en-US',
  { timeZone: 'America/New_York', hour: 'numeric', minute: 'numeric', hour12: false });
const minutesNY = t => {
  const p = fmt.formatToParts(t);
  return (Number(p.find(x => x.type === 'hour').value) % 24) * 60
       + Number(p.find(x => x.type === 'minute').value);
};

function compute(bars) {
  const bg = [];
  const start = Math.max(0, bars.length - 3000);
  let open = null;
  for (let i = start; i < bars.length; i += 1) {
    const m = minutesNY(bars[i].time);
    const inside = m >= 9 * 60 + 30 && m < 16 * 60;
    if (inside && open == null) open = i;
    if (!inside && open != null) { bg.push({ x1: open, x2: i, color: 'rgba(230,81,0,0.09)' }); open = null; }
  }
  if (open != null) bg.push({ x1: open, x2: bars.length, color: 'rgba(230,81,0,0.09)' });
  return { plots: [], bg };
}
```


## Related topics

- [Real-time trading stream](https://docs.hyperprop.com/guides/realtime-trading-stream.md)
- [Webhooks](https://docs.hyperprop.com/guides/webhooks.md)
- [Porting from Pine Script](https://docs.hyperprop.com/indicators/pine-porting.md)
- [Tables](https://docs.hyperprop.com/indicators/tables.md)
- [Other timeframes](https://docs.hyperprop.com/indicators/other-timeframes.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.