ta.change() - Pine Script Function
ta.change()
Section titled “ta.change()”Overview
Section titled “Overview”Compares the current source value to its value length bars ago and returns the difference.
Syntax
Section titled “Syntax”ta.change(source, length) → series intParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| source | series int | Source series. |
Returns
Section titled “Returns”The difference between the values when they are numerical. When a ‘bool’ source is used, returns true when the current source is different from the previous source.
Remarks
Section titled “Remarks”- na values in the source series are included in calculations and will produce an na result.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator('Day and Direction Change', overlay = true)dailyBarTime = time('1D')isNewDay = ta.change(dailyBarTime) != 0bgcolor(isNewDay ? color.new(color.green, 80) : na)isGreenBar = close >= opencolorChange = ta.change(isGreenBar)plotshape(colorChange, 'Direction Change')