update runs, so updating inside an if gives a different result (Pine’s call-site rule, made visible). Values match TradingView’s built-ins, including their seeds and how they treat na.
ta
(length: number): Average
Simple moving average of the last
length values.(length: number): Average
Seeded with the simple average of the first
length values, as TradingView’s ta.ema.(length: number): Average
Wilder’s average, seeded like
ema.(length: number): Average
Linearly weighted moving average: the newest value weighs
length, the oldest 1.(length: number): Average
Hull moving average, a weighted average of weighted averages that lags less.
(length: number): Indicator<[value: number, volume: number], number>
Volume-weighted moving average of the last
length values.(length: number): Average
Standard deviation of the last
length values, over length as TradingView divides (not length - 1).(length: number): Average
Variance of the last
length values, the square of stdev.(length: number): Average
The highest of the last
length values, the current one included.(length: number): Average
The lowest of the last
length values, the current one included.(length: number): Average
Bars since the highest or lowest value in the window, as a negative offset like TradingView’s.
(length: number): Average
(length?: number): Average
value − value
length bars ago.(length: number): Average
Momentum: the value less the value
length bars ago.(length: number): Average
Rate of change: the percent change from the value
length bars ago.(length: number): Average
Relative strength index, 0 to 100, on Wilder’s averages.
(length: number): Average
Commodity channel index: the distance from the
length-bar average in units of mean deviation, over 0.015.(length: number, offset?: number): Average
The least-squares line through the last
length values, read offset bars back from its end (0, the default, is the current bar).(length: number): Average
The percent of the previous
length values that are at or below the current one.(): Average
The running sum of every value since the first bar.
(length: number): Indicator<[value: number], boolean>
True when the value has risen on each of the last
length bars (a step within 1e-10 does not count).(length: number): Indicator<[value: number], boolean>
True when the value has fallen on each of the last
length bars.(): Indicator<[a: number, b: number], boolean>
True on the bar where
a goes from at or below b to above it.(): Indicator<[a: number, b: number], boolean>
True on the bar where
a goes from at or above b to below it.(): Indicator<[a: number, b: number], boolean>
True on the bar where
a crosses b either way.(): Indicator<[condition: boolean], number>
Bars since
condition was last true: 0 on a bar where it is, na until the first time.(occurrence?: number): Indicator<[condition: boolean, value: number], number>
value on the bar where condition was true, the occurrence-th time back (0, the default, is the latest).(left: number, right: number): Indicator<[value: number], number>
A pivot high: a value higher than the
left before it and the right after it. It is known
only right bars later, so it is returned on that bar, na on every other.(left: number, right: number): Indicator<[value: number], number>
A pivot low, as
pivotHigh: returned right bars after the low, na on every other bar.(fast: number, slow: number, signal: number): Indicator<[value: number], MacdValue>
MACD: the fast EMA less the slow EMA, its
signal-bar EMA, and the difference of the two as the histogram.(length: number, mult: number): Indicator<[value: number], BandsValue>
Bollinger Bands: the
length-bar SMA, and bands mult standard deviations either side.(length: number, mult: number, useTrueRange?: boolean): Indicator<[bar: BarView], BandsValue>
Keltner Channels: the
length-bar EMA of the close, and bands mult times the length-bar EMA of the true range (or of the bar’s range) either side.(length: number): Indicator<[close: number, high: number, low: number], number>
Stochastic: where the close sits in the
length-bar range of highs and lows, 0 to 100. Smooth it with ta.sma for %K and %D.(length: number): Indicator<[bar: BarView], number>
Money flow index, 0 to 100: an RSI of the typical price weighted by volume.
(): Indicator<[bar: BarView], number>
On-balance volume: the running sum of volume, added on up closes and taken away on down closes.
(handleNa?: boolean): Indicator<[bar: BarView], number>
True range.
handleNa as TradingView: on the first bar, high − low.(length: number): Indicator<[bar: BarView], number>
Average true range: Wilder’s average of the true range over
length bars.(diLength: number, adxSmoothing: number): Indicator<[bar: BarView], DmiValue>
Directional movement: +DI, -DI and the ADX, which measures trend strength whatever its direction.
(factor: number, atrLength: number): Indicator<[bar: BarView], SupertrendValue>
Supertrend: a trailing line
factor ATRs from the price that flips side when the close crosses it, with its direction.(anchor?: VwapAnchor): Indicator<[bar: BarView], number>
Volume-weighted average price from quote and base volume, reset at each anchor (UTC).
Indicator
(...values: In): Out
Out
The value after the latest update in this run.
Out
The value as of this stream’s last closed bar. Read it from other streams’ handlers.
Average
MacdValue
number
number
number
BandsValue
number
number
number
DmiValue
number
number
number
SupertrendValue
number
number
1 up, -1 down