SmaLayerConfig
Renders a Simple Moving Average (SMA) as a line overlaid on the price panel.
Examples
JSX - Minimal configuration
tsx
<SMA />JSX - Full configuration
tsx
<SMA
id="sma-50"
period={50}
offset={0}
inputs={[{ key: 'input', source: { type: 'price', field: 'close' } }]}
outputs={['value']}
lookback={(period) => period}
calculate={true}
includeInAutoScale={false}
series={{ value: { color: 'orange', width: 1, style: 'solid' } }}
markers={{
value: {
mode: 'last-visible',
line: { color: 'orange', width: 1, style: 'dashed', dashes: [5, 5] },
label: { backgroundColor: 'orange', color: 'white' },
},
}}
legend={{
label: 'SMA 50',
fields: [{ output: 'value', label: '', color: 'orange' }],
}}
yAxis={{ side: 'right', width: 80 }}
/>Configuration Object - Full configuration
ts
{
id: 'sma-50',
type: 'sma',
period: 50,
offset: 0,
inputs: [{ key: 'input', source: { type: 'price', field: 'close' } }],
outputs: ['value'],
lookback: (period) => period,
calculate: true,
includeInAutoScale: false,
series: { value: { color: 'orange', width: 1, style: 'solid' } },
markers: {
value: {
mode: 'last-visible',
line: { color: 'orange', width: 1, style: 'dashed', dashes: [5, 5] },
label: { backgroundColor: 'orange', color: 'white' },
},
},
legend: {
label: 'SMA 50',
fields: [{ output: 'value', label: '', color: 'orange' }],
},
yAxis: { side: 'right', width: 80 },
}Properties
Base Props
type
- Type:
'sma'
offset
- Type:
number - Default:
0
Shifts the SMA line forward or backward by the specified number of bars.
source
- Type:
'open' | 'high' | 'low' | 'close' | 'volume'
Optional shorthand for mapping the SMA input without writing full inputs. If inputs is provided, it takes precedence.
series
- Type:
{ value?: false | LineConfig }
Visual series configuration for SMA.
markers
- Type:
{ value?: false | ValueMarkerConfig }
Value marker configuration for SMA.
Defaults
| Property | Default |
|---|---|
id | 'sma-layer' |
period | 50 |
inputs | close price field |
scale | { key: 'price_auto', domain: 'price', range: { type: 'auto' } } |
includeInAutoScale | false |
series.value | { color: 'orange', style: 'solid', width: 1 } |
TypeScript
ts
interface SmaLayerConfig extends BaseLayerConfig {
type: 'sma';
source?: 'open' | 'high' | 'low' | 'close' | 'volume';
offset?: number;
series?: { value?: false | LineConfig };
markers?: { value?: false | ValueMarkerConfig };
}