Skip to content
Algo Trade Analytics Docs
Pine library page — review pending. This page is preserved for compatibility but is not part of the reviewed search index. Check the official Pine Script v6 reference before relying on its explanation, signature, or example.

ta.change() - Pine Script Function

Compares the current source value to its value length bars ago and returns the difference.

ta.change(source, length) → series int
NameTypeDescription
sourceseries intSource series.

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.

  • na values in the source series are included in calculations and will produce an na result.
//@version=6
indicator('Day and Direction Change', overlay = true)
dailyBarTime = time('1D')isNewDay = ta.change(dailyBarTime) != 0
bgcolor(isNewDay ? color.new(color.green, 80) : na)isGreenBar = close >= opencolorChange = ta.change(isGreenBar)
plotshape(colorChange, 'Direction Change')