0

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 screen

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) 
Max
  • 19
  • 1
  • what is the " different and better classification" in your case? Explain the expected output compared to the current one, otherwise, we can only take a guess. – e2e4 Jun 27 '23 at 12:04
  • The indicator does not correctly show the door changes. Usually the Zigzag is offset by a candle, which then leads to losses during operation. Therefore it would be interesting to set the indicator with several values. In addition, the zigzags are not displayed at the highest point but slightly below. Perhaps there is a query that allows the indicator to be better adjusted in its position on the chart? – Max Jul 05 '23 at 22:33

0 Answers0