Gap and lookahead settings for request.* calls: barmerge.gaps_on, gaps_off, lookahead_on and lookahead_off.
barmerge.gaps_off and barmerge.gaps_on go in the gaps argument of request.security and the other request.* functions. With gaps_off (the default) a bar with no new data repeats the last value. With gaps_on it returns na on every bar except the one where the requested value updates, so you see isolated points.
barmerge.lookahead_off (the default) returns what was known at that moment: a higher-timeframe value updates only once its bar has closed. barmerge.lookahead_on returns the higher-timeframe bar's final value from the first chart bar inside it, so on history the value is known before that bar has closed. That looks wonderful on a backtest and can never happen live.
Constants
| Name | Value | Description |
|---|---|---|
barmerge.gaps_off | Fill bars without new data with the last value; the default. | |
barmerge.gaps_on | Return na on bars without new data. | |
barmerge.lookahead_off | Return only values known at that moment; the default. | |
barmerge.lookahead_on | Return higher-timeframe values from the start of their bar. |
Remarks
- Lookahead is the usual cause of an indicator that repaints or looks too good on history. Leave it off unless you also shift the expression, for example close[1] with
barmerge.lookahead_on, to get the previous completed bar. - On Sidechair:
request.securityruns for the chart's own symbol on the same or a higher timeframe, and both lookahead settings are honoured.
Example
//@version=6
indicator("Merge settings", overlay = true)
dailyClose = request.security(syminfo.tickerid, "D", close, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off)
prevDaily = request.security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on)
plot(dailyClose, "Daily close", color.blue)
plot(prevDaily, "Previous daily close", color.orange)See also
Runs on Sidechair