Lines 15 and 23 reference MONTHLY HA candlesticks as defined in lines 3-6. Since you are in the Weekly and Daily TF, you should define HA candlesticks also for those TF’s.
First you’ll have to remove lines 5-6, since when you later want to refernce the high and low of a HA candlestick you should, I guess, reference the xHighD and xLowD from the DAILY definitions.
For the WEEKLY TF you should add, after line 14 (before line 15):
xCloseW = (open+high+low+close)/4
xOpenW = (xOpenW[1]+xCloseW[1])/2
For the DAILY TF you’ll have to add 4 lines, after line 22 (before line 23):
xCloseD = (open+high+low+close)/4
xOpenD = (xOpenD[1]+xCloseD[1])/2
xHighD = Max(max(high, xOpenD), xCloseD)
xLowD = Min(min(Low, xOpenD), xClosed)
then you’ll have to change references in lines 15 and 23 and in lines 33,36,49,52,65,68,81,84,97 and 100.
But I think also lines with reference to MyDay, MyDay[1] and so on… must be incorrect, but I cannot tell what because the code is too long, and difficult to read and debug.
As I suggested at the beginning, before making a single change you should be confident with the current code. When you’ll be confident with your first change you may add one more (not trwo or three, just one at a time).
Use GRAPH to debug.