Traduzione codice TW RVI

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

    Buongiorno,

    richiedo cortese traduzione di questa versione aggiornata dell’ indicatore RVI, graficamente ben definito.

    Grazie per l’ aiuto.

    https://it.tradingview.com/script/mLZJqxKn-Relative-Volatility-Index/

    #240763 quote
    Iván González
    Moderator
    Master

    Ecco qui:

    //------------------------------------------------------//
    //PRC_RVI relative volatility Index
    //version = 0
    //26.11.2024
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //------------------------------------------------------//
    // Inputs
    //------------------------------------------------------//
    stdevLength=10
    stdevType=1 //boolean variable 1 means Population
    smoothLength=14
    obLevel=60
    osLevel=40
    useRefined=1 //boolean variable
    highlightBreakouts=1 //boolean variable
    src=close
    //------------------------------------------------------//
    // Standard deviation calculation
    //------------------------------------------------------//
    //Type=1 Population else Sample
    if stdevType=1 then
    selectedStdev=STD[stdevLength](src)
    else
    dev=src-average[stdevLength](src)
    variance=summation[stdevLength](pow(dev,2))/(stdevLength-1)
    selectedStdev=sqrt(variance)
    endif
    //------------------------------------------------------//
    // RVI original version (1993)
    //------------------------------------------------------//
    up=(src>=src[1])*selectedStdev
    down=(src<src[1])*selectedStdev
    
    upsum=average[smoothLength,1](up)
    downsum=average[smoothLength,1](down)
    
    rviOriginal=100*upsum/(upsum+downsum)
    //------------------------------------------------------//
    // RVI Refined version (1995)
    //------------------------------------------------------//
    //---High
    upH=(high>=high[1])*selectedStdev
    downH=(high<high[1])*selectedStdev
    
    upsumH=average[smoothLength,1](upH)
    downsumH=average[smoothLength,1](downH)
    
    rviOriginalH=100*upsumH/(upsumH+downsumH)
    
    //---Low
    upL=(low>=low[1])*selectedStdev
    downL=(low<low[1])*selectedStdev
    
    upsumL=average[smoothLength,1](upL)
    downsumL=average[smoothLength,1](downL)
    rviOriginalL=100*upsumL/(upsumL+downsumL)
    
    rviRefined=(rviOriginalH+rviOriginalL)/2
    //------------------------------------------------------//
    // Plot
    //------------------------------------------------------//
    //---Rvi selection
    if useRefined then
    rvi=rviRefined
    else
    rvi=rviOriginal
    endif
    //---Rvi color
    if rvi>oblevel then
    r=14
    g=187
    b=35
    elsif rvi<oslevel then
    r=255
    g=0
    b=0
    else
    r=244
    g=183
    b=125
    endif
    //---HighlightBreakouts
    if rvi>oblevel and highlightBreakouts then
    rob=0
    gob=255
    alphaob=40
    else
    alphaob=0
    endif
    if rvi<oslevel and highlightBreakouts then
    ros=255
    gos=0
    alphaos=40
    else
    alphaos=0
    endif
    colorbetween(100,oblevel,rob,gob,0,alphaob)
    colorbetween(0,oslevel,ros,gos,0,alphaos)
    //------------------------------------------------------//
    return rvi as "RVI" coloured(r,g,b)style(line,2), oblevel as "Overbought Level"coloured("black")style(dottedline),oslevel as "Oversold Level"coloured("black")style(dottedline),50 as "MidLevel" coloured("black")style(dottedline)
    
    Msport71 thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Traduzione codice TW RVI


ProBuilder: Indicatori & Strumenti Personalizzati

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

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

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 11/22/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...