timeframe.change() - Pine Script Function
timeframe.change()
Section titled “timeframe.change()”Overview
Section titled “Overview”Detects changes in the specified timeframe.
Syntax
Section titled “Syntax”timeframe.change(timeframe) → series boolParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| timeframe | series string | String formatted according to the User manual’s timeframe string specifications. |
Returns
Section titled “Returns”Returns true on the first bar of a new timeframe, false otherwise.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6// Run this script on an intraday chart.indicator("New day started", overlay = true)// Highlights the first bar of the new day.isNewDay = timeframe.change("1D")bgcolor(isNewDay ? color.new(color.green, 80) : na)