Sidechair

ta.mom()

Browse the reference

Returns momentum: the current value of source minus its value length bars ago.

Try it in the editor

ta.mom is source - source[length], an absolute price change over the window. It is positive when source is higher than it was length bars back.

The first value appears on bar number length + 1. An na at either end gives na.

Syntax

Pine Script
ta.mom(source: series int/float, length: series int) -> series float

Arguments

NameTypeDefaultDescription
sourceseries int/floatrequiredSeries to compare with its past value.
lengthseries intrequiredHow many bars back to compare. A whole number of 1 or more.

Returns

series float: the difference between source and its value length bars earlier, or na on the first length bars.

Remarks

  • ta.roc expresses the same change as a percentage of the old value.

Example

Pine ScriptTen-bar momentumOpen in editor
//@version=6
indicator("Momentum")
value = ta.mom(close, 10)
plot(value, "Momentum", color = value >= 0 ? color.green : color.red, style = plot.style_histogram)

See also

Runs on Sidechair