Demo
Technical indicators
Documented in Chart analysis.
Technical indicators
Moving averages and Bollinger bands over a candle series, and RSI, momentum, ATR, accumulation distribution, MACD or stochastic in a lower pane, with zones and MACD display options.
Candlestick chart: Technical indicators. No data.
| x | Price |
|---|---|
| Apr 1 | O 50 H 50.8 L 49.3 C 50 V 5,000 |
| Apr 2 | O 52.21 H 54.52 L 51.26 C 53.42 V 6,777 |
| Apr 3 | O 52.3 H 53.7 L 49.88 C 51.08 V 8,554 |
| Apr 4 | O 51.23 H 52.06 L 49.78 C 51.26 V 6,331 |
| Apr 5 | O 51.65 H 53.95 L 50.95 C 52.85 V 8,108 |
| Apr 6 | O 53.99 H 55.39 L 51.81 C 52.76 V 5,885 |
| Apr 7 | O 55.81 H 56.66 L 54.61 C 55.86 V 7,662 |
| Apr 8 | O 55.39 H 57.67 L 53.94 C 56.57 V 5,439 |
| Apr 9 | O 54.22 H 55.62 L 52.27 C 52.97 V 7,216 |
| Apr 10 | O 54.81 H 55.68 L 53.86 C 54.88 V 8,993 |
| Apr 11 | O 57.01 H 59.28 L 55.81 C 58.18 V 6,770 |
| Apr 12 | O 58.22 H 59.62 L 55.52 C 56.97 V 8,547 |
| Apr 13 | O 57.19 H 58.09 L 56.49 C 57.29 V 6,324 |
| Apr 14 | O 55.86 H 58.12 L 54.91 C 57.02 V 8,101 |
| Apr 15 | O 56.49 H 57.89 L 54.03 C 55.23 V 5,878 |
| Apr 16 | O 58.38 H 59.3 L 56.93 C 58.5 V 7,655 |
| Apr 17 | O 58.87 H 61.11 L 58.17 C 60.01 V 5,432 |
| Apr 18 | O 57.24 H 58.64 L 55.01 C 55.96 V 7,209 |
| Apr 19 | O 55.78 H 56.72 L 54.58 C 55.92 V 8,986 |
| Apr 20 | O 56.42 H 58.65 L 54.97 C 57.55 V 6,763 |
| Apr 21 | O 57.92 H 59.32 L 55.93 C 56.63 V 8,540 |
| Apr 22 | O 57.68 H 58.64 L 56.73 C 57.84 V 6,317 |
| Apr 23 | O 55.57 H 57.79 L 54.37 C 56.69 V 8,094 |
| Apr 24 | O 54.12 H 55.52 L 51.38 C 52.83 V 5,871 |
| Apr 25 | O 54.82 H 55.81 L 54.12 C 55.01 V 7,648 |
| Apr 26 | O 55.96 H 58.16 L 55.01 C 57.06 V 5,425 |
| Apr 27 | O 55.13 H 56.53 L 52.63 C 53.83 V 7,202 |
| Apr 28 | O 52.77 H 53.78 L 51.32 C 52.98 V 8,979 |
| Apr 29 | O 51.54 H 53.73 L 50.84 C 52.63 V 6,756 |
| Apr 30 | O 52.42 H 53.82 L 50.16 C 51.11 V 8,533 |
| May 1 | O 53.3 H 54.34 L 52.1 C 53.54 V 6,310 |
| May 2 | O 52.08 H 54.26 L 50.63 C 53.16 V 8,087 |
| May 3 | O 49.75 H 51.15 L 47.74 C 48.44 V 5,864 |
| May 4 | O 48.97 H 50.03 L 48.02 C 49.23 V 7,641 |
| May 5 | O 50.16 H 52.32 L 48.96 C 51.22 V 5,418 |
| May 6 | O 50.92 H 52.32 L 48.14 C 49.59 V 7,195 |
| May 7 | O 49.54 H 50.62 L 48.84 C 49.82 V 8,972 |
| May 8 | O 47.51 H 49.65 L 46.56 C 48.55 V 6,749 |
| May 9 | O 47.36 H 48.76 L 44.83 C 46.03 V 8,526 |
| May 10 | O 48.96 H 50.06 L 47.51 C 49.26 V 6,303 |
| May 11 | O 49.69 H 51.82 L 48.99 C 50.72 V 8,080 |
| May 12 | O 48.33 H 49.73 L 46.04 C 46.99 V 5,857 |
| May 13 | O 46.81 H 47.94 L 45.61 C 47.14 V 7,634 |
| May 14 | O 47.41 H 49.52 L 45.96 C 48.42 V 5,411 |
| May 15 | O 49.4 H 50.8 L 47.36 C 48.06 V 7,188 |
| May 16 | O 50.14 H 51.29 L 49.19 C 50.49 V 8,965 |
| May 17 | O 48.91 H 51 L 47.71 C 49.9 V 6,742 |
| May 18 | O 47.98 H 49.38 L 45.18 C 46.63 V 8,519 |
| May 19 | O 49.29 H 50.46 L 48.59 C 49.66 V 6,296 |
| May 20 | O 51.58 H 53.66 L 50.63 C 52.56 V 8,073 |
| May 21 | O 52.25 H 53.65 L 49.69 C 50.89 V 5,850 |
| May 22 | O 51.15 H 52.34 L 49.7 C 51.54 V 7,627 |
| May 23 | O 50.8 H 52.86 L 50.1 C 51.76 V 5,404 |
| May 24 | O 52.67 H 54.07 L 50.36 C 51.31 V 7,181 |
| May 25 | O 55.05 H 56.27 L 53.85 C 55.47 V 8,958 |
| May 26 | O 55.5 H 57.55 L 54.05 C 56.45 V 6,735 |
| May 27 | O 54.46 H 55.86 L 52.39 C 53.09 V 8,512 |
| May 28 | O 54.56 H 55.8 L 53.61 C 55 V 6,289 |
| May 29 | O 56.77 H 58.79 L 55.57 C 57.69 V 8,066 |
| May 30 | O 58.96 H 60.36 L 56.14 C 57.59 V 5,843 |
| May 31 | O 59.02 H 60.28 L 58.32 C 59.48 V 7,620 |
| Jun 1 | O 57.91 H 59.92 L 56.96 C 58.82 V 5,397 |
| Jun 2 | O 58.29 H 59.69 L 55.71 C 56.91 V 7,174 |
| Jun 3 | O 60.57 H 61.85 L 59.12 C 61.05 V 8,951 |
| Jun 4 | O 62.32 H 64.31 L 61.62 C 63.21 V 6,728 |
| Jun 5 | O 61.82 H 63.22 L 59.49 C 60.44 V 8,505 |
| Jun 6 | O 60.56 H 61.87 L 59.36 C 61.07 V 6,282 |
| Jun 7 | O 61.06 H 63.03 L 59.61 C 61.93 V 8,059 |
| Jun 8 | O 63.17 H 64.57 L 61.08 C 61.78 V 5,836 |
| Jun 9 | O 64.27 H 65.6 L 63.32 C 64.8 V 7,613 |
| Jun 10 | O 63.14 H 65.09 L 61.94 C 63.99 V 5,390 |
| Jun 11 | O 61.7 H 63.1 L 58.86 C 60.31 V 7,167 |
| Jun 12 | O 62.23 H 63.58 L 61.53 C 62.78 V 8,944 |
| Jun 13 | O 64.01 H 65.95 L 63.06 C 64.85 V 6,721 |
| Jun 14 | O 64.39 H 65.79 L 61.8 C 63 V 8,498 |
| Jun 15 | O 62.66 H 64.03 L 61.21 C 63.23 V 6,275 |
| Jun 16 | O 61.1 H 63.02 L 60.4 C 61.92 V 8,052 |
| Jun 17 | O 61.66 H 63.06 L 59.31 C 60.26 V 5,829 |
| Jun 18 | O 63.07 H 64.46 L 61.87 C 63.66 V 7,606 |
| Jun 19 | O 62.76 H 64.65 L 61.31 C 63.55 V 5,383 |
| Jun 20 | O 60.58 H 61.98 L 58.49 C 59.19 V 7,160 |
| Jun 21 | O 59.08 H 60.49 L 58.13 C 59.69 V 8,937 |
| Jun 22 | O 59.73 H 61.61 L 58.53 C 60.51 V 6,714 |
| Jun 23 | O 60.83 H 62.23 L 57.99 C 59.44 V 8,491 |
| Jun 24 | O 59.98 H 61.41 L 59.28 C 60.61 V 6,268 |
| Jun 25 | O 57.61 H 59.46 L 56.66 C 58.36 V 8,045 |
| Jun 26 | O 56.37 H 57.77 L 53.77 C 54.97 V 5,822 |
| Jun 27 | O 57.27 H 58.72 L 55.82 C 57.92 V 7,599 |
| Jun 28 | O 58.17 H 60.01 L 57.47 C 58.91 V 5,376 |
| Jun 29 | O 56.98 H 58.38 L 54.63 C 55.58 V 7,153 |
Demo.tsx
'use client';
import { useState } from 'react';
import { Checkbox } from '@salmonui/inputs/checkbox';
import { NumberField } from '@salmonui/inputs/number-field';
import { Select } from '@salmonui/dropdowns/select';
import { Chart } from '@salmonui/charts/chart';
import type { ChartIndicator } from '@salmonui/charts/chart';
import { technicalIndicators } from '@salmonui/charts/chart/indicators';
const prices = Array.from({ length: 90 }, (_, i) => {
const open = 50 + 6 * Math.sin(i / 9) + i / 10 + 1.5 * Math.sin(i * 1.3);
const close = open + 1.4 * Math.sin(i * 2.1);
return {
date: new Date(Date.UTC(2026, 3, 1 + i)),
open: Math.round(open * 100) / 100,
close: Math.round(close * 100) / 100,
high: Math.round((Math.max(open, close) + 0.8 + (i % 3) * 0.3) * 100) / 100,
low: Math.round((Math.min(open, close) - 0.7 - (i % 4) * 0.25) * 100) / 100,
volume: 5000 + ((i * 1777) % 4000),
};
});
type Overlay = 'none' | 'sma' | 'ema' | 'tma' | 'bollinger';
type Oscillator = 'rsi' | 'momentum' | 'atr' | 'accumulationDistribution' | 'macd' | 'stochastic';
export default function ChartIndicatorsDemo() {
const [overlay, setOverlay] = useState<Overlay>('bollinger');
const [period, setPeriod] = useState(20);
const [oscillator, setOscillator] = useState<Oscillator>('macd');
const [macdDisplay, setMacdDisplay] = useState<'line' | 'histogram' | 'both'>('both');
const [zones, setZones] = useState(true);
const indicators: ChartIndicator[] = [];
if (overlay !== 'none') indicators.push({ kind: overlay, seriesId: 'price', period, deviations: 2, name: overlay === 'bollinger' ? 'Bollinger' : overlay.toUpperCase() });
indicators.push({
kind: oscillator,
seriesId: 'price',
yAxis: 'oscillator',
period: 14,
fastPeriod: 12,
slowPeriod: 26,
signalPeriod: 9,
display: macdDisplay,
kPeriod: 14,
dPeriod: 3,
zones,
});
return (
<div className="demo-stack">
<div className="demo-toolbar">
<label>
Price overlay
<Select aria-label="Price overlay" data={[{ value: 'none', label: 'none' }, { value: 'sma', label: 'SMA' }, { value: 'ema', label: 'EMA' }, { value: 'tma', label: 'TMA' }, { value: 'bollinger', label: 'Bollinger bands' }]} value={overlay} onValueChange={(value) => value != null && setOverlay(value as Overlay)} />
</label>
<label>
Period
<NumberField aria-label="Period" min={2} max={50} value={period} onValueChange={(next) => next != null && setPeriod(next)} style={{ inlineSize: '6em' }} />
</label>
<label>
Lower pane
<Select aria-label="Lower pane" data={[{ value: 'rsi', label: 'RSI' }, { value: 'momentum', label: 'Momentum' }, { value: 'atr', label: 'ATR' }, { value: 'accumulationDistribution', label: 'Accumulation / distribution' }, { value: 'macd', label: 'MACD' }, { value: 'stochastic', label: 'Stochastic' }]} value={oscillator} onValueChange={(value) => value != null && setOscillator(value as Oscillator)} />
</label>
<label>
MACD display
<Select aria-label="MACD display" data={[{ value: 'line', label: 'line' }, { value: 'histogram', label: 'histogram' }, { value: 'both', label: 'both' }]} value={macdDisplay} onValueChange={(value) => value != null && setMacdDisplay(value as 'line' | 'histogram' | 'both')} disabled={oscillator !== 'macd'} />
</label>
<Checkbox checked={zones} onCheckedChange={(checked) => setZones(checked)} disabled={oscillator !== 'rsi' && oscillator !== 'stochastic' && oscillator !== 'momentum'}>Zones</Checkbox>
</div>
<Chart
title="Technical indicators"
data={prices}
height={420}
timeZone="UTC"
locale="en-US"
features={[technicalIndicators]}
panes={{ rows: ['65%', '35%'] }}
xAxis={{ format: 'MMMd' }}
axes={[{ id: 'oscillator', direction: 'y', pane: { row: 1 }, title: oscillator === 'accumulationDistribution' ? 'A/D' : oscillator.toUpperCase() }]}
series={[{ id: 'price', type: 'candle', name: 'Price', xField: 'date', openField: 'open', highField: 'high', lowField: 'low', closeField: 'close', volumeField: 'volume' }]}
indicators={indicators}
/>
</div>
);
}
indicators is plain data: change the selects and the chart lays out
again (there is no refresh method). SMA, EMA, TMA and Bollinger bands
(period, deviations: 2) share the price axis; the lower-pane indicator
names yAxis: 'oscillator', an axis placed in the second row of
panes. RSI and stochastic draw their overbought / oversold zones,
MACD takes fastPeriod, slowPeriod, signalPeriod and display, and
accumulation distribution reads the series' volumeField. The indicator
code is the opt-in technicalIndicators feature from
@salmonui/charts/chart/indicators.