Hello,
I have attached some simple code that grabs the previously closed MACD values from a 2-hour timeframe. After running this on 30 seconds, I noticed that a significant portion of time does not display any returned values whatsoever. On top of that, when opening a 2-hour chart and manually checking the values that are returned, they do not match up.
This problem doesn’t occur when running the code on 1 minute.
I was hoping someone could shed some light on this because I don’t understand what could be causing this problem.
Cheers,
timeframe(2 hours)
hist2H = MACD[12, 26, 9](Close)[1]
line2H = MACDLine[12, 26, 9](Close)[1]
timeframe(default)
return hist2H, line2H
Did you have enough units on your chart?
Bear in mind that to calculate MACD, 26 (+ some extra ones for calculations + an extra one due to using [1] with CLOSE) 2-hour periods are required, each one of them requiring 7200 seconds (3600 each hour) for a number of seconds which totals roughly 200K seconds.
I think that using 30 seconds, instead of a mere 1-second TF won’t earn you 30 times the periods, but almost the same ones.
Do not embed files of any type in your post, as this slows down loading the pages.
Attach them using the SELECT FILE button only.
Thank you 🙂