MTF and Repainting
This page is where the timing model lives. It covers the `On Bar Close?` switch, the request posture that shapes it, the chart-versus-slot-timeframe rule, the session-versus-rolling posture, the intrabar history fallb...
Written By Axiom Admin
Last updated 22 days ago
MTF and Repainting
This page is where the timing model lives. It covers the On Bar Close? switch, the request posture that shapes it, the chart-versus-slot-timeframe rule, the session-versus-rolling posture, the intrabar history fallback, the divergence module's confirmation timing, and the display-time honesty of Plot On Pivot. Everything here is something a careful reader needs to internalize before they tune anything beyond defaults.
Read the whole page. The sections interlock.
The core tension
Every multi-timeframe indicator has to pick a side of a honest tradeoff: either it waits for higher-timeframe bars to close before reading them, or it reads them live and updates as they form. Waiting is slower and settled. Reading live is faster and can change until the bar closes. Neither posture is "correct" β both exist for good reasons. What matters is that the indicator is honest about which posture it is in, and that the user can pick.
STR gives the user the pick. Each slot has its own On Bar Close? switch inside its Power User group. Default is ON.
On Bar Close, ON
When On Bar Close? is ON, the slot reads the prior slot-bar value β the settled value from the bar that has already closed. The slot's output does not change until the next slot bar closes. In practical terms, a slot on the 60-minute timeframe on a 5-minute chart holds its value for twelve 5-minute bars at a time, then updates once at the close of each hour.
What this gives you:
Settled reads. The slot's state and the alerts that depend on it cannot flip mid-bar.
Honest backtests. The historical value at every bar is the value the slot was producing at that bar; nothing retroactively changes.
A known lag. The slot's output is one slot-bar behind live. You know exactly how much lag you are looking at.
What you pay for it:
Latency. The slot cannot tell you anything about the current slot bar until it closes.
Flat periods. Between slot-bar closes, the slot's output is constant. A reader looking for moment-to-moment change inside a long slot bar will not find it.
This is the default and the honest posture for chart review and for backtests. It is also the posture most process-oriented traders should keep most of the time.
On Bar Close, OFF
When On Bar Close? is OFF, the slot reads the live slot-bar value as the slot bar is still forming. The slot's output updates in real time and can change until the slot bar closes.
What this gives you:
Real-time behavior. You see pressure on the current slot bar as it develops.
Faster state changes. A slot can flip its state inside the slot bar; the resulting alert fires on the next confirmed chart bar where the state holds.
What you pay for it:
The slot can repaint until the slot bar closes. A slot that read "bullish" halfway through the hour can settle as "bearish" by the hour's close. The historical record of that slot will show the settled value, not the mid-bar value. A backtest run against a recording of the live pane will not match a backtest run against settled history.
Some workflow patterns that rely on historical consistency stop being safe. Do not scale a backtested process built on OFF-mode behavior without understanding that the settled line in history is not the live line you acted on.
A concrete way this catches readers: imagine a discretionary trader watching slot 3 (60-minute) on a 5-minute chart with On Bar Close? OFF. Twenty minutes into the hour, slot 3 is reading 72 β clearly bullish, above its signal, fill is lime. The trader takes a position based partly on that read. By the close of the hour, fresh participation rolls in and slot 3 settles at 48 β neutral, signal crossed back the other way. The historical chart, opened tomorrow, will show 48 at that hourly bar. The trader's screenshots will show 72 at the moment of the decision. Both are honest records of two different things β the live read and the settled value. Neither is wrong. They are simply not the same number, and a backtest cannot distinguish them.
OFF is a legitimate choice for readers who understand it. It is the wrong choice if you have not explicitly thought about the above cost.
The request posture that underlies both modes
The indicator uses request.security with lookahead = barmerge.lookahead_on. That posture is the standard way to avoid a classic MTF repainting pattern β a pattern where the indicator appears to "see" future data in historical replay because it is reading the next bar's open-time value without shifting.
Combined with the [1] shift under On Bar Close ON, the slot's output at each bar is the most recent settled value as of that bar. Not a leaked value from the future. Not a value that retroactively changes when you reload the chart.
Under On Bar Close OFF, the slot's current-bar value is whatever the live higher-timeframe bar is currently showing. That is honest live behavior β the slot is reporting the live state of the higher-timeframe bar at this moment β not hidden future leakage. The value can and does change until the higher-timeframe bar closes.
The script is not "non-repainting by default." Under ON, the settled output does not repaint. Under OFF, it can. Calling the indicator simply "non-repainting" without naming the OFF case would be wrong.
The chart-vs-slot-timeframe rule
A slot's timeframe must be greater than or equal to the chart timeframe. If you set a slot to 1-minute while the chart is on 5-minute, the indicator will throw a runtime error. The error names the slot.
Why the rule exists: a higher-resolution read per slot bar than the chart bar is asking for resolution the chart bar cannot carry. A 5-minute chart has exactly one bar every five minutes; a 1-minute slot would have to invent information the chart bar does not contain. Rather than silently producing nonsense, the indicator refuses.
Verification: set a slot's timeframe to 1-minute on a 5-minute chart and read the runtime error message wording. The slot label will be in the message so you can fix the right slot.
Lower-timeframe precision
Each slot reads intrabar OHLCV at a lower timeframe β Lower TF Precision β to estimate signed volume inside each slot bar. That precision must be strictly lower than the slot's own timeframe.
If the precision is equal to or higher than the slot's timeframe, the indicator throws a runtime error.
Why: the intrabar walk counts intrabars of the precision inside each slot bar. If the precision equals the slot, there is one intrabar per slot bar, and the walk is trivial. If the precision exceeds the slot, there is no intrabar per slot bar, and the walk is impossible. Either case is a misconfiguration.
Verification: set a slot's lower-TF precision equal to its timeframe and read the runtime error message.
Intrabar history fallback
TradingView serves intrabar data across a limited history window. When you scroll the chart back far enough, intrabar data ages out and is not available to the estimator.
When that happens, the slot falls back to estimating delta from the slot bar's own OHLCV using a fallback function. The line continues to draw. The fallback is a cruder estimate β less granular than the intrabar walk. The line does not visually announce the change.
How to see it:
Pick a slot at a precision whose intrabar window is known (for example, a precision of 1-minute has a shorter intrabar history window than 5-minute on most data feeds).
Scroll the chart back past that window.
Watch the slot's line behavior. More abrupt, more quantized transitions are the fallback speaking.
Why this matters:
For live trading on recent bars, the fallback is rarely active β you are reading the estimator at its intended precision.
For backtests spanning long history, the estimator is reading at precision on recent bars and at fallback on older bars. A backtest that treats every bar as reading the same estimate is comparing apples to slightly-different apples.
Mitigation: choose a lower-TF precision whose history window covers your backtest window. Higher precisions (smaller LTF) age out faster. Lower precisions (larger LTF) age out more slowly.
Window Length vs slot timeframe
The slot's Window Length β the Session anchor in Session mode, or the Rolling lookback duration in Rolling mode β must be greater than or equal to the slot's timeframe. The indicator throws a runtime error if it is not.
Why: a window shorter than the slot would reset before the slot had accumulated a single slot bar's worth of delta. The value would be meaningless.
Verification: set a slot's window to a duration smaller than its timeframe and read the error.
Session vs rolling
Each slot has a Window Mode:
Session: accumulation resets at each window anchor. The anchor is typically daily (
D), weekly (W), or a timezone string. In Session mode, the indicator draws a dashed vertical line in the slot's color at each reset, visible whenHide Plotis OFF. In session mode, the slot's value after a reset starts from its fresh normalization range; early bars after a reset can move widely against small accumulated evidence.Rolling: accumulation is a sliding window of
Window Lengthduration. No reset marker β by design, because there is no reset event. The window is continuously rolling.
Both produce different lines from the same data. Neither is universally correct. Use Session when you want a per-session accounting of delta; use Rolling when you want a continuous pressure read that does not reset at a fixed clock event.
Verification:
In Session mode, set
Window LengthtoDon an intraday chart. Confirm the rollover dash lands at the daily boundary for the instrument's exchange.In Rolling mode, confirm no rollover dash appears. The line evolves smoothly across what would be session boundaries in Session mode.
A slot pointed at an Optional Ticker with a different session will have its reset marker land on that symbol's session boundary, not the chart's. That mismatch is expected; it requires you to hold the mismatch in mind while you read the slot.
Divergence confirmation timing
The divergence module is gated differently from the state-descriptor alerts, and the difference matters.
The divergence flag is computed inside a block that requires three conditions: the module is enabled, the bar is confirmed (barstate.isconfirmed), and the pivot comparison has just produced a new valid geometric pattern against the previous pivot pair. The pivot functions themselves β ta.pivothigh and ta.pivotlow with pivot strength n on both sides β need n confirmed bars to the right of the pivot before they return a non-na value.
What that means for timing:
The divergence flag can only flip true on a confirmed bar, never mid-bar.
The confirmation bar is
Pivot Lenbars after the pivot bar itself. A divergence against a pivot that happened an hour ago on a 5-minute chart withPivot Lenof 20 will confirm an hour and forty minutes later β 20 bars of 5 minutes each.The confirmation delay is the cost of a strict pivot definition. It is not a flaw; it is the price of asking the module to wait until the geometry is actually done forming.
Plot On Pivot β the display-time honesty control
Plot On Pivot controls where the triangle marker appears. It does not control when the alert fires and it does not change the confirmation bar.
Plot On PivotOFF (default). The triangle prints on the confirmation bar. The marker sitsPivot Lenbars after the actual pivot. The alert fires on the same bar.Plot On PivotON. The triangle is visually shifted back byPivot Lenbars to sit on the original pivot bar. The alert still fires on the confirmation bar. The marker was not visible at the pivot bar in real time.
This is the single most important honesty control on the indicator. Read the following carefully.
A reader who studies the pane with Plot On Pivot ON will see triangles landing on the pivot bars themselves. The visual will feel intuitive β the geometry is there, the marker is there, the moment seems aligned. But the alert that flagged the triangle did not fire at that earlier bar; it fired Pivot Len bars later, at the confirmation bar. The back-shifted marker is a display convenience. It is honest about where the geometry formed. It is silent about when the script could have known. The visual lays the geometry over a moment in time at which the script had no information about it.
In live trading, the instinct trained by Plot On Pivot ON will fail. You will reach for a decision based on the marker's visual position and the decision will be at the wrong bar. The cost is not theoretical: a reader who has practiced reading triangles on the pivot bar in replay will, in live conditions, expect a triangle that has not yet appeared and may not appear for many bars. By the time it does appear, the chart and the pressure read have both moved on, and the bar the marker visually claims belongs to a moment whose pane has already changed. Every page in this pack is reinforcing the same point because it is the failure mode that costs readers the most when they hit it for real.
The guidance is strict:
Leave
Plot On PivotOFF in your working configuration. Alert bar and marker bar coincide. The pane is telling you what it knows, at the bar it knows it.Use
Plot On PivotON only for chart review, and only after you have internalized the timing difference. The ON mode is useful for studying where the geometry actually formed across a history of divergences; it is not useful for live reading.Never teach someone else to read the pane with
Plot On PivotON. They will form the wrong instinct.
Verification:
Put
Plot On Pivoton OFF. Wait for a confirmed divergence. Note the bar the triangle appears on. That is the confirmation bar.Toggle
Plot On Pivotto ON on the same chart. The triangle will shift left byPivot Lenbars. The visual position moves. The alert evaluation bar did not move.Toggle back to OFF and confirm the triangle returns to the confirmation bar.
Verification walkthrough for the whole timing model
One setup that touches every claim on this page in sequence:
Add the indicator to a 5-minute chart of a liquid instrument.
Open the slot-1 Power User group. Toggle
On Bar Close?OFF for slot 1. Watch slot 1's line behavior during the current slot bar. Note that it jitters or updates as the bar forms. ToggleOn Bar Close?back to ON. Note that the line now holds its value between slot-bar closes.Still in slot 1: set TimeFrame to
1(one minute). Read the runtime error message.Set TimeFrame back to
5. SetLower TF Precisionto5. Read the runtime error message. Set Lower TF Precision back to1.Scroll the chart back several weeks. Watch slot 1's line behavior change as intrabar data ages out.
Set
Window Modeon slot 1 toSessionandWindow LengthtoD. Confirm a dashed vertical appears at each daily reset.Set
Window ModetoRolling. Confirm no dash appears at the daily boundary.With the divergence module on, wait for a confirmed divergence. Note the confirmation-bar position of the triangle with
Plot On PivotOFF.Toggle
Plot On Pivotto ON. Note the triangle shifts exactlyPivot Lenbars to the left to sit on the pivot bar.Toggle back to OFF.
After that sequence, every behavior on this page has been seen firsthand on a real chart.
Where to go next
For the alert surface that sits under the timing model, Alerts.
For the honest limits that this page's posture creates, Limitations and Trust Boundaries.
For the participation model that runs inside each slot at the chosen precision, For the Geeks.
When a timing-related symptom does not match what you expect, Troubleshooting.