ZigZag + condizione

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #253131 quote
    Edisone
    Participant
    Average

    Salve a tutti sto utilizzando lo script ZigZag di Iván González che allego. Avrei la necessità di evidenziare con un simbolo quando si verifica una sequenza specifica di valori, nello specifico: LL → HH → HL.
    È possibile implementarlo? Se sì, come potrei fare?

    Grazie in anticipo per l’aiuto!

    //------------------------------------//
    //PRC_ZigZag and SR
    //version = 0
    //03.12.2024
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //------------------------------------//
    // Inputs
    //------------------------------------//
    //prd=5
    //showSR=1 //Show Support and Resistance//Boolean// 0 means false 1 means True
    //showLabels=1 //Boolean// 0 means false 1 means True
    //showZZ=0 //Boolean// 0 means false 1 means True
    atr=averagetruerange[14](close)
    //------------------------------------//
    // Calculate Pivot High and Low
    //------------------------------------//
    ph = high=highest[prd](high)
    pl = low=lowest[prd](low)
    //------------------------------------//
    // Calculate Direction
    //------------------------------------//
    if ph and pl=0 then
    dir=1
    elsif pl and ph=0 then
    dir=-1
    else
    dir=dir
    endif
    dirchanged=dir<>dir[1]
    //------------------------------------//
    // Calculate ZizZag levels and x
    //------------------------------------//
    if ph or pl then
    if dirchanged then
    if dir=1 then
    $zigzag[t+1]=highest[prd](high)
    $zigzagidx[t+1]=barindex
    $dir[t+1]=1
    t=t+1
    elsif dir=-1 then
    $zigzag[t+1]=lowest[prd](low)
    $zigzagidx[t+1]=barindex
    $dir[t+1]=-1
    t=t+1
    endif
    else
    if dir=1 and highest[prd](high)> $zigzag[t] then
    $zigzag[t]=highest[prd](high)
    $zigzagidx[t]=barindex
    elsif dir=-1 and lowest[prd](low)< $zigzag[t] then
    $zigzag[t]=lowest[prd](low)
    $zigzagidx[t]=barindex
    endif
    endif
    endif
    //------------------------------------//
    // Draw ZigZag and Levels
    //------------------------------------//
    $zigzag[0]=undefined
    $zigzagidx[0]=undefined
    if islastbarupdate then
    if showZZ then
    //Last ZigZag
    drawsegment($zigzagidx[max(0,t-1)],$zigzag[max(0,t-1)],$zigzagidx[t],$zigzag[t])
    endif
    if showSR and $dir[t]=1 then
    drawsegment($zigzagidx[t],$zigzag[t],barindex,$zigzag[t])style(dottedline,3)coloured("green")
    drawsegment($zigzagidx[max(0,t-1)],$zigzag[max(0,t-1)],barindex,$zigzag[max(0,t-1)])style(dottedline,3)coloured("red")
    if $zigzag[t]<$zigzag[t-2] then
    drawtext("HL",$zigzagidx[t],$zigzag[t]+0.5*atr)coloured("green")
    else
    drawtext("HH",$zigzagidx[t],$zigzag[t]+0.5*atr)coloured("green")
    endif
    elsif showSR and $dir[t]=-1 then
    drawsegment($zigzagidx[t],$zigzag[t],barindex,$zigzag[t])style(dottedline,3)coloured("red")
    drawsegment($zigzagidx[max(0,t-1)],$zigzag[max(0,t-1)],barindex,$zigzag[max(0,t-1)])style(dottedline,3)coloured("green")
    if $zigzag[t]<$zigzag[t-2] then
    drawtext("LL",$zigzagidx[t],$zigzag[t]-0.5*atr)coloured("red")
    else
    drawtext("LH",$zigzagidx[t],$zigzag[t]-0.5*atr)coloured("red")
    endif
    endif
    if showLabels then
    drawpoint($zigzagidx[max(0,t-1)],$zigzag[max(0,t-1)],2)coloured("blue",100)
    drawpoint($zigzagidx[t],$zigzag[t],2)coloured("blue",100)
    endif
       
    //Draw all ZigZag
    for i=t-1 downto 3 do
    if showZZ then
    drawsegment($zigzagidx[max(0,i-1)],$zigzag[max(0,i-1)],$zigzagidx[i],$zigzag[i])
    endif
    if showSR and $dir[i]=1 then
    drawsegment($zigzagidx[i],$zigzag[i],$zigzagidx[i+1],$zigzag[i])style(dottedline,3)coloured("green")
    drawsegment($zigzagidx[max(0,i-1)],$zigzag[max(0,i-1)],$zigzagidx[i],$zigzag[max(0,i-1)])style(dottedline,3)coloured("red")
    elsif showSR and $dir[i]=-1 then
    drawsegment($zigzagidx[i],$zigzag[i],$zigzagidx[i+1],$zigzag[i])style(dottedline,3)coloured("red")
    drawsegment($zigzagidx[max(0,i-1)],$zigzag[max(0,i-1)],$zigzagidx[i],$zigzag[max(0,i-1)])style(dottedline,3)coloured("green")
    endif
          
    if showLabels and $dir[i]=-1 and $zigzag[i]>$zigzag[i-2] then
    drawtext("LH",$zigzagidx[i],$zigzag[i]-0.5*atr)coloured("red")
    elsif showLabels and $dir[i]=-1 and $zigzag[i]<=$zigzag[i-2] then
    drawtext("LL",$zigzagidx[i],$zigzag[i]-0.5*atr)coloured("red")
    elsif showLabels and $dir[i]=1 and $zigzag[i]>$zigzag[i-2] then
    drawtext("HH",$zigzagidx[i],$zigzag[i]+0.5*atr)coloured("green")
    elsif showLabels and $dir[i]=1 and $zigzag[i]<=$zigzag[i-2] then
    drawtext("HL",$zigzagidx[i],$zigzag[i]+0.5*atr)coloured("green")
    endif
    next
    endif
    //------------------------------------//
    return
    

    #253136 quote
    JS
    Participant
    Senior
    Ciao, Non credo che le etichette siano corrette in questo indicatore… La “LH” e la “HL” sono state scambiate…
    #253137 quote
    Iván González
    Moderator
    Master
    Ciao. Aggiungi questo all’interno del ciclo finale:
    IF i >= 5 THEN   
    isLH = ($dir[i] = -1 AND $zigzag[i] > $zigzag[i-2])
    isHH = ($dir[i-1] = 1 AND $zigzag[i-1] > $zigzag[i-3])   
    isLL = ($dir[i-2] = -1 AND $zigzag[i-2] <= $zigzag[i-4])   
    
    IF isLH AND isHH AND isLL THEN
    DRAWTEXT("LL-HH-LH", $zigzagidx[i], $zigzag[i] - 1.5 * atr) COLOURED(0, 0, 255)
    ENDIF
    ENDIF
    robertogozzi thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

ZigZag + condizione


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
Edisone @edisone Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by Iván González
3 months ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 10/29/2025
Status: Active
Attachments: No files
Logo Logo
Loading...