Skip to content
ChartTailor
WorkServicesPricingField NotesAbout Start a build
← Pine Discoveries

timeframe.multiplier is not the timeframe

A Pine script that reads only the numeric multiplier can misunderstand seconds, minutes, days, weeks, and months.

timeframe.multiplier is useful, but it is not the timeframe. It is the numeric part of the current chart interval. That sounds obvious until a script uses it as if it were a complete identity. A multiplier of 1 can mean one second, one minute, one day, one week, or one month depending on the chart.

I started keeping a note on this because timeframe bugs often hide inside scripts that work perfectly on the author’s favorite chart. Then the user changes to seconds, daily, weekly, or a custom interval and the logic quietly means something else.

Why this catches people

Where people usually go wrong is using the multiplier to scale lengths or sessions without checking the timeframe family. On a 5-minute chart, multiplying by five may make sense. On a 5-second chart or a 5-day chart, the same calculation may be nonsense. The number is not enough.

Pine provides other timeframe helpers for a reason. timeframe.period, timeframe.isintraday, timeframe.isseconds, timeframe.isdaily, timeframe.isweekly, timeframe.ismonthly, and conversion helpers can all be part of a safer design. The script should use the helper that matches the question it is asking.

The Pine bit

If the question is “what text should I show the user?”, timeframe.period may be the right value. If the question is “is this an intraday chart?”, use the boolean family. If the question is “how many seconds does this bar represent?”, use a conversion approach instead of guessing from the multiplier alone.

This becomes important in multi-timeframe scripts that build request timeframes dynamically. A script that assumes multiplier * 3 means “three times the current timeframe” can generate invalid or unintended requests when the chart moves across timeframe families.

tfSeconds = timeframe.in_seconds(timeframe.period)
isFastIntraday = timeframe.isintraday and tfSeconds <= 15 * 60

How I handle it in builds

In practical scripts, I usually avoid dynamic timeframe construction unless there is a strong reason. Option lists are less clever, but they are easier to support. If the user can choose 5 minutes, 15 minutes, 1 hour, or 1 day from a controlled input, the script is less likely to generate a strange request on an unexpected chart.

When dynamic logic is needed, I include guards. The script can warn on unsupported chart types or fall back to a default. That is better than silently using a value that looked right only because the multiplier was familiar.

Where this shows up

The bug often appears in code that tries to scale a moving average or session window automatically. A “20 bars on the current chart” setting is not the same as “roughly 20 minutes” unless the current chart is one minute. If the script intends duration, it should calculate duration. If it intends bar count, it should say bar count.

I like to expose this distinction in input names. “Lookback bars” and “Lookback minutes” are different controls. When those names are clear, users stop expecting one to behave like the other. Pine has enough timeframe helpers that the script does not need to pretend the multiplier alone carries all of that meaning.

I test timeframe logic with deliberately awkward charts: 45 minutes, 2 hours, seconds charts, weekly charts, and monthly charts. If the script only works on 5, 15, and 60 minutes, that may be acceptable, but it should be constrained to those choices. Silent support for every timeframe is not the same as real support.

How I test it

I test timeframe logic on awkward intervals, not only the common ones. Seconds, 45-minute charts, daily, weekly, and monthly charts reveal whether the code understands the timeframe or merely worked on the developer’s favorite interval.

Checks before I trust it

  • Do not use timeframe.multiplier without checking the timeframe family.
  • Use timeframe.period when the script needs the chart’s actual interval string.
  • Use conversion helpers when the logic needs seconds.
  • Prefer option lists for user-selected higher timeframes when possible.
  • Test scripts on seconds, intraday minutes, daily, weekly, and monthly charts.

The practical takeaway is that the multiplier is only a piece of the timeframe. Treating it as the whole thing is how scripts become accidentally chart-specific.