Hi,
Below is the code snippet which plots a line connecting the highs and lows and highlights the length of wave of the move. I would appreciate if someone could give an idea about the code and the logic of how the coordinates of line/wave is calculated.
Sample output below where the blue line is plotted based on the above code.
Thanks in advance.
Below is the code snippet which plots a line connecting the highs and lows and highlights the length of wave of the move. I would appreciate if someone could give an idea about the code and the logic of how the coordinates of line/wave is calculated.
Code:
period = param("Zig-Zag %age Change", 1, 0.1, 30, 0.1);
zz_c = paramcolor("Zig-Zag Line Color", colorblue);
zz_s = paramstyle("Zig-Zag Line Style", styleline | stylethick, maskall);
zz_w = param("Zig-Zag Line Width", 2, 1, 10, 1);
pk = peakbars(h, period) == 0;
tr = troughbars(l, period) == 0;
zzhi = zig(h, period);
zzlo = zig(l, period);
avg = (zzhi + zzlo) / 2;
x = iif(pk, zzhi, iif(tr, zzlo, iif(avg > ref(avg,-1), h, l)));
zzhilo = zig(x, period);
plot(zzhilo, "zzhl", zz_c, zz_s, 0, 0, 0, 0, zz_w);
Thanks in advance.