How can you get the value of the Macd Line and Signal Line real-time from different timeframe. Like for example I am on a 4HR chart and I want to get the value of the Macd Line and Signal Line from the 1 hr timeframe.
I know how to get the value of the two lines it is just that I cannot solve or find the value from the other timeframe. [macdLine, signalLine, histLine] = macd(close, 12, 26, 9)
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 callsDaily MACD, signal and histogram data from the Daily chart.
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: