Zig Zag High Low

7290 views
Zig Zag script that uses local minimums and maximums as pivot points . It can be used as a source for pattern recognition.

Does it account for different timeframes?
Virking_online
@Virking_online, it uses only "current" timeframe
Will this change the final leg after price moves?
colibribull
@colibribull, yes, it can

Thanks again for your help! I love the community... Strength in numbers!

-Anthony
is it possible to add a 50% Fib of a Zig and plot it on the Zag and Vice-Versa ?
Hey, Tr0st! Great indicator...

I'm trying to get the RSI to appear at the Pivot highs, but I can't figure out how to do it... it's always offset... I'm trying to use the code:

rsiVal = rsi(close, 14)

to get the RSI and

label.new(bar_index, na, text=tostring(rsiVal), color=color.red, textcolor=color.white, style=label.style_label_up, yloc=yloc.belowbar)

Can you help me with the final piece to this puzzle?

Thanks!
ocaptain
@ocaptain, use this line as a guidance
line.new(
timeHigh - length, lastHigh,
timeLow - length, lastLow,
xloc.bar_index, color=_li_color, width=2
)

It contains coordinates of pivot points
Tr0sT
@Tr0sT, Thanks for your response! Yep, I figured out the offset problem with that very line of code you pointed out... Now I just have a problem displaying the right value... I'm trying to make a running variable asking "if the current high is greater than the recorded high, get the RSI. Then when your code prints the line, I print the value of the RSI (14 close) above it but it never matches the value of the built-in indicator.

var rsiVal = 0.0
if high > lastHigh
rsiVal := round(rsi(close, 14))

Then under the 'if dirup' line I added this to display the label:

label.new(timeHigh-length, na, text=tostring(rsiVal), color=color.red, textcolor=color.white, style=label.style_label_down, yloc=yloc.abovebar)

It's weird because the value displayed in the label isn't even an RSI value anywhere within the vicinity of the pivot high - I don't know where that value is coming from.

Again, I appreciate your help! -Anthony