Traduzione codice TW Zig Zag invincible

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #241033 quote
    Msport71
    Participant
    Junior

    Buongiorno,

    chiedo cortese traduzione del seguente codice.

    Grazie per l’aiuto.

    https://www.tradingview.com/script/zdjIB3Bh-Zigzag3-Invincible3/

    #241036 quote
    Iván González
    Moderator
    Master

    Ecco qui:

    //------------------------------------//
    //PRC_ZigZag and SR
    //version = 0
    //03.12.2024
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //------------------------------------//
    // Inputs
    //------------------------------------//
    prd=18
    showSR=1 //Show Support and Resistance//Boolean// 0 means false 1 means True
    showLabels=1 //Boolean// 0 means false 1 means True
    showZZ=1 //Boolean// 0 means false 1 means True
    //------------------------------------//
    // 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")
    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")
    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 1 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 then
    drawpoint($zigzagidx[i],$zigzag[i],2)coloured("blue",100)
    endif
    next
    endif
    //------------------------------------//
    return
    #241038 quote
    Msport71
    Participant
    Junior

    Grazie e mille, gentilissimo !

    #241110 quote
    Renero
    Participant
    New

    Ciao, ho provato incollare il programma ma mi da errore alla riga 64,67,68. Dallo screenshot si può vedere tutto. Cosa posso fare?

    #241122 quote
    robertogozzi
    Moderator
    Master

    Probabilmente non l’hai copiato tra gli indicatori.

    Dalla foto mi sembra che tu l’abbia messo erroneamente tra le strategie.

    Iván González thanked this post
    #241130 quote
    Renero
    Participant
    New

    Probabilmente non l’hai copiato tra gli indicatori.

    Dalla foto mi sembra che tu l’abbia messo erroneamente tra le strategie.

    Eh si proprio così errore mio.

    Grazie e buona giornata

    #244769 quote
    Msport71
    Participant
    Junior

    Buongiorno,

     

    cortesemente si potrebbe aggiungere all’indicatore il conteggio dei punti che intercorrono tra uno swing e l’altro?

     

    Grazie e mille per l’aiuto

    #245013 quote
    robertogozzi
    Moderator
    Master

    Eccolo:

    //------------------------------------//
    //PRC_ZigZag and SR
    //version = 0
    //03.12.2024
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //------------------------------------//
    // Inputs
    //------------------------------------//
    prd=18
    showSR=1 //Show Support and Resistance//Boolean// 0 means false 1 means True
    showLabels=1 //Boolean// 0 means false 1 means True
    showZZ=1 //Boolean// 0 means false 1 means True
    ONCE PrevSwing = 0
    ONCE CurrSwing = 0
    //------------------------------------//
    // 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")
    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")
    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
    PrevSwing = 0
    CurrSwing = 0
    for i=t-1 downto 1 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 then
    PrevSwing  = CurrSwing
    CurrSwing  = $zigzag[i]
    Difference = CurrSwing - PrevSwing
    drawpoint($zigzagidx[i],$zigzag[i],2)coloured("blue",100)
    Offset     = (range*0.5)
    myPRICE    = $zigzag[i] + Offset
    IF Difference <= 0 THEN
    myPRICE    = $zigzag[i] - Offset
    ENDIF
    drawtext("#Difference#",$zigzagidx[i],myPRICE,dialog,bold,10) coloured("Fuchsia")
    endif
    next
    endif
    //------------------------------------//
    return

    Per variare la distanza del testo sostituisci alla riga 98 il valore 0.5 con un altro valore (0, 0.1, 1, 1.2, ecc…) a tuo piacimento.

    Per variare la grandezza del testo sostituisci alla riga 103 il valore 10 con un altro valore (6, 11, 20, ecc…) a tuo piacimento.

    Iván González thanked this post
    #245014 quote
    robertogozzi
    Moderator
    Master

    Per cambiare i colori puoi usare i nomi (o i codici) indicati in questa tabella https://cloford.com/resources/colours/500col.htm.

    Msport71 thanked this post
    #245019 quote
    Msport71
    Participant
    Junior

    grazie e mille, gentilissimo.

    robertogozzi thanked this post
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

Traduzione codice TW Zig Zag invincible


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
Msport71 @carlo-pasca Participant
Summary

This topic contains 9 replies,
has 4 voices, and was last updated by Msport71
10 months, 3 weeks ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 12/03/2024
Status: Active
Attachments: 2 files
Logo Logo
Loading...