Returns the difference between the current value of source and its value length bars ago; for a bool source, whether it differs.
For numbers, ta.change is source - source[length], with length defaulting to 1. For a bool source it returns true on the bars where the value differs from the value length bars earlier.
The first length bars return na for numbers. Use it to spot a new session, a flipped condition or a price step.
Syntax
ta.change(source: series int/float, length: series int) -> series float
ta.change(source: series bool, length: series int) -> series bool
ta.change(source: series int, length: series int) -> series intArguments
| Name | Type | Default | Description |
|---|---|---|---|
| source | series int/ | required | Series to compare with its past value; numbers or booleans. |
| length | series int | 1 | How many bars back to compare. A whole number of 1 or more. |
Returns
series float: the difference from length bars ago, or na on the first length bars.series bool: true when the value differs from length bars ago.series int: the integer difference from length bars ago.
Remarks
ta.change(close)is the same as close - close[1].
Example
//@version=6
indicator("Change")
delta = ta.change(close)
plot(delta, "Change", color = delta >= 0 ? color.green : color.red, style = plot.style_columns)See also
Runs on Sidechair