Non-Repainting Higher-Timeframe Data Requests in Trading Scripts
Summary
This indicator demonstrates ways to request data from a timeframe higher than the chart timeframe while controlling whether values can change as the higher-timeframe bar develops. Its main non-repainting method offsets the requested expression by one higher-timeframe bar and uses lookahead so chart bars receive the most recently confirmed higher-timeframe value. The script also wraps that logic in a helper function and shows how to apply it to tuple requests.
A comparison request uses default settings to illustrate how historical and realtime values can differ after a script restarts. The example lets users choose a fixed higher timeframe or a multiple of the chart timeframe, and checks that the selection is actually higher. These are implementation examples, not a trading strategy or evidence of profitability. The offset means the non-repainting methods use confirmed prior-bar data, which can make their values arrive later than a developing higher-timeframe reading; the repainting option instead accepts changing values.
Key ideas
- An offset of one higher-timeframe bar paired with lookahead can provide confirmed data without historical future leakage.
- A helper function can centralize the repainting choice for individual expressions.
- Tuple requests can use the same offset and lookahead logic directly in the request.
- Default higher-timeframe requests may behave differently across historical and realtime bars.
- The requested timeframe must be greater than the chart timeframe.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.