conversione Relative Volatility Index RVI

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #243454 quote
    joelse
    Participant
    New

    Buondì, qualcuno è in grado di convertire il codice PINE di questo indicatore? mi sembra interessante

     

    //@version=6
    indicator(title=”Relative Volatility Index”, shorttitle=”RVI”, format=format.price, precision=2, timeframe=””, timeframe_gaps=true)
    length = input.int(10, minval=1)
    offset = input.int(0, “Offset”, minval = -500, maxval = 500)
    src = close
    len = 14
    stddev = ta.stdev(src, length)
    upper = ta.ema(ta.change(src) <= 0 ? 0 : stddev, len)
    lower = ta.ema(ta.change(src) > 0 ? 0 : stddev, len)
    rvi = upper / (upper + lower) * 100
    h0 = hline(80, “Upper Band”, color=#787B86)
    hline(50, “Middle Band”, color=color.new(#787B86, 50))
    h1 = hline(20, “Lower Band”, color=#787B86)
    fill(h0, h1, color=color.rgb(126, 87, 194, 90), title=”Background”)
    plot(rvi, title=”RVI”, color=#7E57C2, offset = offset)
    // Smoothing MA inputs
    GRP = “Smoothing”
    TT_BB = “Only applies when ‘SMA + Bollinger Bands’ is selected. Determines the distance between the SMA and the bands.”
    maTypeInput = input.string(“SMA”, “Type”, options = [“None”, “SMA”, “SMA + Bollinger Bands”, “EMA”, “SMMA (RMA)”, “WMA”, “VWMA”], group = GRP, display = display.data_window)
    maLengthInput = input.int(14, “Length”, group = GRP, display = display.data_window)
    bbMultInput = input.float(2.0, “BB StdDev”, minval = 0.001, maxval = 50, step = 0.5, tooltip = TT_BB, group = GRP, display = display.data_window)
    var enableMA = maTypeInput != “None”
    var isBB = maTypeInput == “SMA + Bollinger Bands”
    // Smoothing MA Calculation
    ma(source, length, MAtype) =>
    switchMAtype
    “SMA”=>ta.sma(source,length)
    “SMA + Bollinger Bands”=>ta.sma(source,length)
    “EMA”=>ta.ema(source,length)
    “SMMA (RMA)”=>ta.rma(source,length)
    “WMA”=>ta.wma(source,length)
    “VWMA”=>ta.vwma(source,length)
    // Smoothing MA plots
    smoothingMA = enableMA ? ma(rvi, maLengthInput, maTypeInput) : na
    smoothingStDev = isBB ? ta.stdev(rvi, maLengthInput) * bbMultInput : na
    plot(smoothingMA, “RVI-based MA”, color=color.yellow, display = enableMA ? display.all : display.none, editable = enableMA)
    bbUpperBand = plot(smoothingMA + smoothingStDev, title = “Upper Bollinger Band”, color=color.green, display = isBB ? display.all : display.none, editable = isBB)
    bbLowerBand = plot(smoothingMA – smoothingStDev, title = “Lower Bollinger Band”, color=color.green, display = isBB ? display.all : display.none, editable = isBB)
    fill(bbUpperBand, bbLowerBand, color= isBB ? color.new(color.green, 90) : na, title=”Bollinger Bands Background Fill”, display = isBB ? display.all : display.none, editable = isBB)
    #243580 quote
    Iván González
    Moderator
    Master

    Ciao. Este indicador ya fue traducido hace unos meses. Ha aggiunto las bandas de bollinger e la media mobile

    //------------------------------------------------------//
    //PRC_RVI relative volatility Index
    //version = 0
    //06.02.2025
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //------------------------------------------------------//
    // Inputs
    //------------------------------------------------------//
    stdevLength=10
    stdevType=1 //boolean variable 1 means Population
    smoothLength=14
    obLevel=80
    mdLevel=50
    osLevel=20
    useRefined=1 //boolean variable
    highlightBreakouts=1 //boolean variable
    src=close
    maTypeInput=0
    maLengthInput=14
    useBB=1
    bbMultInput=2
    //------------------------------------------------------//
    // 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)
    
    rvi=100*upsum/(upsum+downsum)
    //------------------------------------------------------//
    // Moving average
    //------------------------------------------------------//
    maRVI=average[maLengthInput,maTypeInput](rvi)
    if useBB then
    bbUpperband=maRVI+std[maLengthInput](rvi)*bbMultInput
    bbLowerband=maRVI-std[maLengthInput](rvi)*bbMultInput
    endif
    //------------------------------------------------------//
    // Plot
    //------------------------------------------------------//
    //---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),maRVI as "MA RVI"coloured("blue"), oblevel as "Overbought Level"coloured("black")style(dottedline),oslevel as "Oversold Level"coloured("black")style(dottedline),50 as "MidLevel" coloured("black")style(dottedline),bbUpperband as "BBUp"coloured("blue")style(dottedline),bbLowerband as "BBDn"coloured("blue")style(dottedline)
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

conversione Relative Volatility Index RVI


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
joelse @joelse Participant
Summary

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

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