ta.spread
Take the bar by bar difference of two series, such as two instruments.
ta.spread(a, b)a - b, bar by bar. It can be written as a plain subtraction. The id gives a cross-instrument spread a name the clock rule attaches to: a declared series lands on the chart's clock as of each chart bar, completed bars only, so ta.spread(close, d.close) is an as-of difference and never a peek at a forming bar.
Parameters
A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.
| Name | Kind | Type | Default | Range | Description |
|---|---|---|---|---|---|
a | Series | number | - | - | The series to read. |
b | Series | number | - | - | The series to read. |
Output
| Name | Type |
|---|---|
value | number |
Warm-up and missing values
- Warm-up
- None.
- Missing values
- na when either series is na on this bar. Pointwise: no window, no warm-up.
Example
ta.spread(close, open)spy = series(symbol="SPY")
plot(ta.spread(close, spy.close), "Spread")