macd pivot

I’m trying to use a showbar to show a weekly macd pivot on a daily chart. When I compare charts side by side the showbar on the daily chart is not at the same point (time), as the macd pivot on the weekly chart. This is the script I have tried.

o1 = OSC(Week(PERIODAMOUNT=1), BARS1=12, BARS2=24, STYLE=Exponential);
p1 = PIVOT(Week(PERIODAMOUNT=1), o1, MIN=22, TYPE=Both);
l1 = (o1 < 0) and (p1 < 0);

l1

Any advice to solving this issue?

Thanks Peter

Hi Peter,

MACD has its own scripting function, OSC() is for other tools, so the values won’t match.

Additionally as the Pivot is calculated from the MACD data you don’t need to set a Time Frame override on that line, just the MACD.

The adjusted script is:

V1 = MACD(Week(PERIODAMOUNT=1), BAR1=12, BAR2=24);
V2 = PIVOT(V1, MIN=22) ;
V1 < 0 and V2 < 0

On the chart the Show Bars on the daily time frame match those on the Weekly:

Ex1