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

Higher-timeframe values need a trust label

A multi-timeframe Pine script should distinguish completed higher-timeframe data from developing values and impossible history.

Higher-timeframe data is one of the best reasons to use Pine and one of the easiest ways to fool yourself with it. A five-minute chart that knows the daily close can be useful. A five-minute chart that appears to know the daily close before the day has finished is a different thing. The code may only be one offset away from changing the whole meaning of the signal.

The reason this matters in real scripts is that multi-timeframe scripts often look clean even when their timing is not. The higher-timeframe line plots smoothly, the dashboard cell updates, and the user sees a value. The missing question is whether that value was completed, developing, or impossible at that point in time.

Why this catches people

The trap is to ask request.security() for a value and then treat the returned series as self-explanatory. It is not. The request has a timeframe, an expression, a merge behaviour, and sometimes a lookahead setting. The expression itself may include an offset. Those choices decide what the lower-timeframe bar is allowed to know.

A developing daily value can be valid if the script says it is developing. It becomes dangerous when it is displayed like a confirmed daily close or used in a backtest as if it were final. The chart does not automatically tell the user which version they are seeing.

The Pine bit

I like to name higher-timeframe values by trust state. dailyCloseDeveloping and dailyCloseConfirmed are wordy, but they are harder to misuse. If the script needs the last completed daily close on an intraday chart, the expression usually needs to ask for the previous higher-timeframe value in a way that does not leak the current day’s final result into history.

The important habit is to narrate the value on a specific lower-timeframe bar. On this five-minute bar, what daily value am I using? Did the day already close? If not, am I intentionally using a developing value?

confirmedDailyClose = request.security(
     syminfo.tickerid,
     "D",
     close[1],
     lookahead = barmerge.lookahead_on)

How I handle it in builds

In dashboards, I often expose the trust state visually. A developing value can be dimmer, marked as live, or kept out of confirmed signal counts. That prevents the dashboard from implying that every cell has the same quality of evidence.

For strategies, I am stricter. If a backtest uses higher-timeframe values, the code has to prove that it did not use future information. A small offset mistake can turn a weak strategy into a beautiful report.

Where this shows up

A good practical example is a daily trend filter on a five-minute chart. A developing daily close can flip above and below the daily moving average all day. A confirmed daily close changes only after the daily bar has closed. Both are useful, but they answer different trading questions. One says “where is today’s daily candle right now?” The other says “what did the last completed daily candle prove?”

I like to make that distinction visible in dashboards by using words like Live, Developing, or Confirmed. It keeps the user from counting a live higher-timeframe value as if it were final evidence. That small label can prevent a lot of confusion around repainting accusations.

This is also a naming problem. A variable called dailyTrend is too vague in a serious script. developingDailyTrend and confirmedDailyTrend may feel verbose, but the names prevent accidental reuse. If the code later adds alerts, tables, or strategy rules, the timing choice is still visible. That is a small price to pay for avoiding a hidden future-data bug.

How I test it

I test multi-timeframe logic at timeframe boundaries. The first lower-timeframe bars after a new higher-timeframe period are where timing mistakes show up. If the script is honest there, it is usually honest in the easier middle of the period.

Checks before I trust it

  • Name higher-timeframe values as confirmed or developing.
  • Review the requested expression and the lookahead setting together.
  • Avoid using a final higher-timeframe value before that timeframe has closed.
  • Display developing dashboard values differently from confirmed ones.
  • Explain the timing choice before trusting a multi-timeframe backtest.

The thing worth preserving is that higher-timeframe data needs a trust label. Once the script names what it knows, the chart becomes much harder to fool.