I have a zigzag indicator that actually works well. Unfortunately, the division of the Zigzag line is not optimal. Zigzag changes are not placed at the correct high and low points. Is it possible to give the script a different and better classification? So far I haven't found any way to improve the classification. Does anyone have any idea how to do the classification. thank you
Here the script:
//@version=5
strategy("Test 37", process_orders_on_close=true, max_bars_back = 4000, overlay=true, max_lines_count=500, max_labels_count=500, calc_on_every_tick=true)
ZZPercent = input.float(0.45, title="Minimum % Change")
trend = 0
trend := na(trend[1]) ? 1 : trend[1]
LL = 0.0
LL := na(LL[1]) ? low : LL[1]
HH = 0.0
HH := na(HH[1]) ? high : HH[1]
PivotChg = ZZPercent * 0.01
float zigzag = na
if (trend > 0) // trend is up, look for new swing low
if (high >= HH) // new higher high detected
HH := high
//label.new(bar_index, na, "", color=color.rgb(233, 7, 7), textcolor=color.black, style=label.style_label_down, yloc=yloc.belowbar)
else
if (low < HH * (1 - PivotChg))
zigzag := high[1]
trend := -1
LL := low
// Short- Auslöser
if (low < HH * (1 - PivotChg))
label.new(bar_index[0], na, "", color=color.rgb(240, 53, 6), textcolor=color.black, style=label.style_label_down, yloc=yloc.abovebar)
alert("SS_Alert Short " + str.tostring(tick), alert.freq_once_per_bar) // , freq = alert.freq_all alert.freq_once_per_bar
trade_preis_short := close
last_trade_richtung == "short"
else // trend is down, look for new swing high
if (low <= LL) // new lower low detected
LL := low
//label.new(bar_index, na, "", color=color.green, textcolor=color.black, style=label.style_label_up, yloc=yloc.belowbar)
else
if (high > LL * (1 + PivotChg))
zigzag := low[1]
trend := 1
HH := high
plot(series=zigzag, linewidth=4, style=plot.style_line, color=color.rgb(238, 198, 22), offset=-1)