You can use security
function to access higher timeframe data, but trying to access lower than your chart's timeframes will lead to unreliable results in Pine Script version < 5, as TV doesn't support intrabar data there. In Pine Script V5, an additional request.security_lower_tf() function was added to handle this case.
You can also include tuple in the security
function calls
Daily MACD, signal and histogram data from the Daily chart.
[macdLineD, signalLineD, histLineD] = security(syminfo.tickerid, "D", [macdLine, signalLine, histLine])
Security
function could lead to repainting, check this article how to avoid the issue - https://www.tradingview.com/script/cyPWY96u-How-to-avoid-repainting-when-using-security-PineCoders-FAQ/
non-repainting version use the previous resolution value with lookahead argument set to true:
[macdLineD, signalLineD, histLineD] = security(syminfo.tickerid, "D", [macdLine[1], signalLine[1], histLine[1]], lookahead = true)