Traduzione indicatore da Tradingview a Pro Real Time

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #234106 quote
    Hunry86Hunry86
    Participant
    New

    Buonasera,

    come da titolo richiedo se è possibile tradurre il seguente indicatore https://www.tradingview.com/script/ls35sRAp-ZigZag-With-ATR-Filter-vnhilton/

    Allego il file con il codice.

    Indicatore-da-tradurre.txt
    #234692 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Buenas. Ecco il codice dell'indicatore.

    pivotlength=3
    
    //Check if pivotlength is odd
    if (pivotlength-1) mod 2 = 0 then
    pivotlength=pivotlength
    else
    pivotlength=pivotlength+1
    endif
    
    atrmultiplier=2
    atr=averagetruerange[(pivotlength-1)/2]
    
    once $pivotIndices[0]=barindex
    once $pivotValues[0]=high
    once $pivotTypes[0]=1
    once z=0
    
    //-----------------------------------------------------//
    //-----Looking for at least 1 instance where a pivot cannot be created
    noHighPivot=0//a pivot can be created
    noLowPivot=0//a pivot can be created
    
    for i=pivotlength-1 to 1 do
    //check left side bar
    if i>(pivotlength-1)/2 then
    if high[i]>high[i-1] then
    noHighPivot=1//a pivot cannot be created
    endif
    if low[i]<low[i-1] then
    noLowPivot=1//a pivot cannot be created
    endif
    endif
    //check middle and right side bar
    if i<=(pivotlength-1)/2 then
    if high[i]<high[i-1] then
    noHighPivot=1//a pivot cannot be created
    endif
    if low[i]>low[i-1] then
    noLowPivot=1//a pivot cannot be created
    endif
    endif
    next
    //-----------------------------------------------------//
    updatelast=0
    if isset($pivotindices[z]) then
    
    if $pivotTypes[z]=1 then
    if not noHighpivot and high[(pivotlength-1)/2]>$pivotValues[z] then
    $pivotIndices[z]=barindex-((pivotLength-1)/2)
    $pivotValues[z]=high[(pivotLength-1)/2]
    $pivotVolume[z]=summation[max(1,($pivotIndices[z]-$pivotIndices[max(0,z-1)]))](volume)
    updatelast=1
    endif
    
    if not noLowPivot and abs(low[(pivotlength-1)/2]-$pivotValues[z])>=atr*atrMultiplier and (barindex-(pivotlength-1)/2) <> $pivotIndices[z] and low[(pivotlength-1)/2]<$pivotValues[z] then
    $pivotIndices[z+1]=barindex-((pivotLength-1)/2)
    $pivotValues[z+1]=LOW[(pivotLength-1)/2]
    $pivotTypes[z+1]=-1
    $pivotVolume[z+1]=summation[($pivotIndices[z+1]-$pivotIndices[z])](volume)
    z=z+1
    endif
    
    else
    
    if not noLowpivot and low[(pivotlength-1)/2]<$pivotValues[z] then
    $pivotIndices[z]=barindex-((pivotLength-1)/2)
    $pivotValues[z]=low[(pivotLength-1)/2]
    $pivotVolume[z]=summation[max(1,($pivotIndices[z]-$pivotIndices[max(0,z-1)]))](volume)
    updatelast=1
    endif
    
    if not noHighPivot and abs(high[(pivotlength-1)/2]-$pivotValues[z])>=atr*atrMultiplier and (barindex-(pivotlength-1)/2) <> $pivotIndices[z] and high[(pivotlength-1)/2]>$pivotValues[z] then
    $pivotIndices[z+1]=barindex-((pivotLength-1)/2)
    $pivotValues[z+1]=high[(pivotLength-1)/2]
    $pivotTypes[z+1]=1
    $pivotVolume[z+1]=summation[($pivotIndices[z+1]-$pivotIndices[z])](volume)
    z=z+1
    endif
    
    endif
    else //If it will be the first Pivot
    if not noHighPivot then  
    $pivotIndices[z+1]=barindex-((pivotLength-1)/2)
    $pivotValues[z+1]=high[(pivotLength-1)/2]
    $pivotTypes[z+1]=1
    $pivotVolume[z+1]=summation[($pivotIndices[z+1]-$pivotIndices[z])](volume)
    z=z+1
    endif
    if not noLowPivot then 
    $pivotIndices[z+1]=barindex-((pivotLength-1)/2)
    $pivotValues[z+1]=LOW[(pivotLength-1)/2]
    $pivotTypes[z+1]=-1 
    $pivotVolume[z+1]=summation[($pivotIndices[z+1]-$pivotIndices[z])](volume)
    z=z+1
    endif
    endif
    
    //Get Trend
    if z>=2 then
    if $pivotTypes[z]=1 and $pivotValues[z] > $pivotValues[z-2] then
    $trend[z]=2 
    elsif $pivotTypes[z]=1 and $pivotValues[z] <= $pivotValues[z-2] then
    $trend[z]=1
    elsif $pivotTypes[z]=-1 and $pivotValues[z] < $pivotValues[z-2] then
    $trend[z]=-2
    elsif$pivotTypes[z]=-1 and $pivotValues[z] >= $pivotValues[z-2] then
    $trend[z]=-1
    endif
    else
    $trend[z]=0
    endif
    //-----------------------------------------------------//
    if islastbarupdate then
    for j=z downto 1 do
    vol=$pivotVolume[j]
    if $pivotTypes[j]=1 and $trend[j]=2 then
    drawtext("HH",$pivotIndices[j],$pivotValues[j]+atr)
    drawtext("#vol#",$pivotIndices[j],$pivotValues[j]+2*atr)
    drawsegment($pivotIndices[j-1],$pivotValues[j-1],$pivotIndices[j],$pivotValues[j])style(line,2)coloured("orange")
    elsif $pivotTypes[j]=1 and $trend[j]=1 then
    drawtext("LH",$pivotIndices[j],$pivotValues[j]+atr)
    drawtext("#vol#",$pivotIndices[j],$pivotValues[j]+2*atr)
    drawsegment($pivotIndices[j-1],$pivotValues[j-1],$pivotIndices[j],$pivotValues[j])style(line,2)coloured("orange")
    elsif $pivotTypes[j]=-1 and $trend[j]=-2 then
    drawtext("LL",$pivotIndices[j],$pivotValues[j]-atr)
    drawtext("#vol#",$pivotIndices[j],$pivotValues[j]-2*atr)
    drawsegment($pivotIndices[j-1],$pivotValues[j-1],$pivotIndices[j],$pivotValues[j])style(line,2)coloured("orange")
    elsif $pivotTypes[j]=-1 and $trend[j]=-1 then
    drawtext("HL",$pivotIndices[j],$pivotValues[j]-atr)
    drawtext("#vol#",$pivotIndices[j],$pivotValues[j]-2*atr)
    drawsegment($pivotIndices[j-1],$pivotValues[j-1],$pivotIndices[j],$pivotValues[j])style(line,2)coloured("orange")
    endif
    next
    endif
    //-----------------------------------------------------//
    return 
    
    #234773 quote
    Hunry86Hunry86
    Participant
    New

    Grazie mille sei stato gentilissimo!!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Traduzione indicatore da Tradingview a Pro Real Time


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
Hunry86 @hunry86 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Hunry86Hunry86
2 years, 2 months ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 06/19/2024
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...