CONVERSION INDICADOR NADARAYA WATSON ENVELOPE:

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #239247 quote
    Azkune
    Participant
    New

    Solicito, si es posible, convertir el indicador adjunto:

    El indicador Nadaraya Watson Envelope esta creado por LuxAlgo. Este indicador se basa en los suavizadores de Nadaraya-Watson publicados anteriormente. Aquí hemos creado un indicador de envolvente basado en Kernel Smoothing con alertas integradas de cruces entre el precio y los extremos de la envolvente.

    https://www.tradingview.com/script/Iko0E2kL-Nadaraya-Watson-Envelope-LuxAlgo/

    A ver si Iván el moderador tiene un hueco libre y lo puede traducir.
    Muchas gracias.

    #239250 quote
    robertogozzi
    Moderator
    Master
    #239260 quote
    Azkune
    Participant
    New

    No es lo mismo. Hice la prueba de poner los dos indicadores en dos pantallas y no dan la misma respuesta como se puede ver en la dirección de las líneas. Además, de que no da ninguna señal o estéticamente es diferente.

    #239269 quote
    robertogozzi
    Moderator
    Master

    Entiendo, esperemos a que Iván lo verifique y pueda hacerlo.

    #239273 quote
    jesus1975
    Participant
    Veteran

    Repinta

    #239274 quote
    jesus1975
    Participant
    Veteran
    #239295 quote
    Azkune
    Participant
    New

    Espero que Iván lo pueda verificar, porque yo lo he hecho y tal como lo he puesto arriba no es lo mismo.

    #239687 quote
    Iván González
    Moderator
    Master

    Buenas! Os paso las 2 opciones, con repintado y sin repintado.

    //--------------------------------------------//
    //PRC Nadaraya-Watson Envelope
    //version = 0
    //28.02.24
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //--------------------------------------------//
    //-----------Inputs---------------------------//
    //--------------------------------------------//
    h1=8 //Bandwidth
    mult=3
    length=499 //Window Size
    repaint=1
    src=close
    //--------------------------------------------//
    //----------Repaint ON------------------------//
    //--------------------------------------------//
    if islastbarupdate and repaint then
    sae=0
    for i=0 to min(499,barindex-1) do
    sum=0
    sumw=0
    for j=0 to min(499,barindex-1) do
    x=i-j
    w=exp(-(pow(x,2)/(h1*h1*2)))
    sum=src[j]*w+sum
    sumw=w+sumw
    next
    $y2[i]=sum/sumw
    sae=sae+abs(src[i]-$y2[i])
    next
    
    sae1=sae/min(499,barindex-1)*mult
    
    for i=min(499,barindex-1) downto 0 do
    if i MOD 2 <> 0 then
    drawpoint(barindex[i],$y2[i]+sae1,2)coloured("green")
    drawpoint(barindex[i],$y2[i]-sae1,2)coloured("red")
    endif
    if close[i]>$y2[i]+sae1 and close[i+1]<=$y2[i+1]+sae1 then
    drawarrowdown(barindex[i],high[i])coloured("red")
    elsif close[i]<$y2[i]-sae1 and close[i+1]>=$y2[i+1]-sae1 then
    drawarrowup(barindex[i],low[i])coloured("green")
    endif
    next
    endif
    //--------------------------------------------//
    //----------Repaint OFF-----------------------//
    //--------------------------------------------//
    if repaint=0 then
    once init = 1
    
    If init = 1 then
    den = 0
    For i = 0 to length-1 do
    $coefs[i]=exp(-(i*i)/(h1*h1*2))
    den = den + $coefs[i]
    Next
    init = 0
    Endif
    
    out = 0
    
    For i = 0 to length-1 do
    out = out + src[i]*$coefs[i]
    Next
    
    out = out/den
    mae = exponentialAverage[length](abs(src-out)) * mult
    
    upper = out + mae
    lower = out - mae
    
    if close crosses over upper then
    drawarrowdown(barindex,high)coloured("red")
    elsif close crosses under lower then
    drawarrowup(barindex,low)coloured("green")
    endif
    endif
    //--------------------------------------------//
    //----------Plot Bands------------------------//
    //--------------------------------------------//
    if repaint then
    up=undefined
    dw=undefined
    else
    up=upper
    dw=lower
    endif
    //--------------------------------------------//
    return up as "Upper band"style(line,2)coloured("Green"),dw as "Lower band"style(line,2)coloured("red")
    
    #240056 quote
    Azkune
    Participant
    New

    Hola,

    Perdón, pero no entiendo muy bien desde dónde hasta dónde debo copiar cada opción.

    Gracias

    Un saludo

    #240064 quote
    Iván González
    Moderator
    Master

    Sólo tienes que cambiar el valor de la línea 13. Repaint=1 es verdadero y Repaint=0 falso.

    #240506 quote
    deletedaccount22102025
    Participant
    New

    Hola Iván, el indicador ofrece el mismo resultado que el de Tradingview pero ralentiza Prorealtime. De hecho me aparce un mensaje que tiene un lag de cálculo en el indicador y no tengo un equipo lento precisamente. Hay alguna manera de acelerar esto?. Un saludo

    #240517 quote
    Iván González
    Moderator
    Master

    Buenas. El problema es que hay muchos bucles…
    Una opción sería modificar la variable length puesto que los loops tienen en cuenta esta variable.
    Otra opción sería calcular sólo el indicador en las últimas X velas utilizando la instrucción en la primera línea DEFPARAM Calculateonlastbars=300

    #240633 quote
    deletedaccount22102025
    Participant
    New

    Muchas gracias Iván. Un saludo

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

CONVERSION INDICADOR NADARAYA WATSON ENVELOPE:


ProBuilder: Indicadores y Herramientas

New Reply
Author
author-avatar
Azkune @azkune Participant
Summary

This topic contains 12 replies,
has 5 voices, and was last updated by deletedaccount22102025
1 year, 2 months ago.

Topic Details
Forum: ProBuilder: Indicadores y Herramientas
Language: Spanish
Started: 10/19/2024
Status: Active
Attachments: No files
Logo Logo
Loading...