Posts

Showing posts with the label timeframe.multiplier

Handling Timeframes in Pine Script v6: timeframe.period and timeframe.multiplier Explained

Image
When building indicators or strategies that must behave differently depending on whether the user is viewing a 1-minute chart versus a daily chart, Pine Script v6 provides two essential built-in variables: timeframe.period and timeframe.multiplier . Understanding how these two variables work together allows you to write scripts that dynamically adapt their logic to any chart resolution without hardcoding timeframe assumptions. 1. What Are timeframe.period and timeframe.multiplier ? Pine Script v6 exposes several built-in timeframe.* variables that describe the chart's current resolution at runtime. The two most important for dynamic adaptation are: Variable Type Description Example (1H chart) timeframe.period simple string The full timeframe string of the current chart (e.g., "60", "D", "W") "60" ...