Convertir indicador Relative Volatility Index

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #245008 quote
    micky_red
    Participant
    New

    Hola, me gustaría solicitar si es posible convertir el indicador de TradingView que adjunto:

    Más info del indicador en: Índice de volatilidad relativa — TradingView

    Adjunto una imagen de su ventana de parámetros, así como su código fuente.

    Muchas gracias por adelantado.  ¡Saludos!

    //@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) =>
    	switch MAtype
    		"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)
    parametros-rvi.jpg parametros-rvi.jpg
    #245049 quote
    Iván González
    Moderator
    Master

    Hola. Este indicador ya fue traducido hace unos meses.

    https://www.prorealcode.com/topic/conversione-di-codice-pine/

    #245063 quote
    micky_red
    Participant
    New

    Muchas gracias Iván por responder.

    Lo he estado probando y el resultado es aproximado pero no exacto.

    Te he adjuntado unas capturas de pantalla del indicador cargado y funcionando en el DAX de hoy en PRT así como en TradingView, te he señalado las diferencias para ver si podrías ayudarme a ajustarlo para que el resultado sea el mismo.

    Muchas gracias por adelantado!

    Captura1.jpg Captura1.jpg Captura2.jpg Captura2.jpg captura3.jpg captura3.jpg captura4.jpg captura4.jpg
    #245088 quote
    Iván González
    Moderator
    Master

    Hola. ten en cuenta que las cotizaciones no son exactamente iguales por lo que verás diferencias.

    #245089 quote
    micky_red
    Participant
    New

    Hola Iván, si lo he tenido en cuenta y entiendo que puede haber alguna variación.

    A pesar de ello, si comparamos los RSI se ven exactamente iguales, mientras en el RVI hay variaciones notables, por eso pienso que quizás exista algún parámetro que pueda ajustarse para que el resultado sea lo más parecido posible.

    En fin, si pudieras revisarlo te lo agradecería muchísimo.

     

    Saludos.

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

Convertir indicador Relative Volatility Index


ProBuilder: Indicadores y Herramientas

New Reply
Author
author-avatar
micky_red @micky_red Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by micky_red
11 months, 2 weeks ago.

Topic Details
Forum: ProBuilder: Indicadores y Herramientas
Language: Spanish
Started: 03/18/2025
Status: Active
Attachments: 5 files
Logo Logo
Loading...