What request.security does
request.security lets your script pull a series from a different timeframe or symbol. The basic form:
dailyClose = request.security(syminfo.tickerid, "D", close)
This gives you the daily close as a series on any intraday chart.
Look-ahead bug #1: repainting
If you call request.security(... , close) on a 1H chart, you are pulling the daily close — but during the day, the daily bar is still forming, so the value changes as new hourly bars arrive. Your 1H chart will repaint in real time. Pine has a built-in guard:
dailyClose = request.security(syminfo.tickerid, "D", close, lookahead=barmerge.lookahead_off)
This is now safe — you get the prior daily close until the current daily bar closes.
Look-ahead bug #2: same-bar decisions
If your strategy uses the daily close to decide whether to enter on the next 1H bar, make sure the daily close you read is actually closed. Use barmerge.lookahead_off and remember that intraday strategies can only act on data that was closed before the decision bar.
The tuple-return pattern
You can pull multiple series in one call:
[dHigh, dLow, dClose] = request.security(syminfo.tickerid, "D", [high, low, close], lookahead=barmerge.lookahead_off)
Common MTF build: higher-TF trend filter
ema200 = request.security(syminfo.tickerid, "D", ta.ema(close, 200), lookahead=barmerge.lookahead_off) longSignal = ta.crossover(close, ta.ema(close, 20)) and close > ema200 shortSignal = ta.crossunder(close, ta.ema(close, 20)) and close < ema200
Only trade with the daily trend. Trend filters cut drawdown roughly in half on most intraday strategies — the math is well-documented in the CTA literature.
Performance warning
Every request.security call adds execution time. Pine's limit is generous but you can hit it with dozens of calls per bar. If you find your chart lagging, count your security calls.