1
votes

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)

2

2 Answers

1
votes

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, as TV doesn't support intrabar data.

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)
-1
votes

With security Functions. security(syminfo.tickerid,"{Your timeframe},