Variable Moving Average

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #31331 quote
    bolsatrilera
    Participant
    Master

    Buenos días , estoy intentando hacer una versión para Prorealtime v10.3 del indicador Variable Moving Average aparecido en la plataforma Tradingview creado por Lazy Bear : https://es.tradingview.com/script/6Ix0E5Yr-Variable-Moving-Average-LazyBear/

    Tengo este esbozo de código,pero algo estoy haciendo mal…no sale nada.¿Alguién puede echarme una mano?

    REM VARIABLE MOVING AVERAGE
    //código original de LazyBear para la plataforma Tradingview
    //media exponencial desarrollada por Tushar S. Chande
    //adaptación para la plataforma Prorealtime v10.3
    //en el cuadro de variables nz= tipo Boleano
    
    
    src=close
    I=6
    K=1.0/I
    pdm=max((src-src[1]),0)
    mdm=max((src[1]-src),0)
    pdmS=((1-K)*(pdmS[nz]) + K*pdm)
    mdmS=((1-K)*(mdmS[nz]) + K*mdm)
    s=pdmS + mdmS
    pdi=pdmS/s
    mdi=mdmS/s
    pdis=((1-K)*(pdis[nz])+ K*pdi)
    mdis=((1-K)*(mdis[nz])+ K*mdi)
    d=abs(pdis - mdis)
    s1=pdis+mdis
    IS=((1-K)*(IS[nz])+K*d/s1)
    hhv=highest[I](IS)
    llv=lowest[I](IS)
    d1=hhv-llv
    v1=(IS-llv)/d1
    vma=(1-K*v1)*(vma[nz])+K*v1*src
    
    if vma then
    if vma >vma[1] then
    r=0
    g=255
    b=0
    endif
    
    if vma<vma[1] then
    r=255
    g=0
    b=0
    endif
    
    if vma=vma[1] then
    r=0
    g=0
    b=255
    else
    r=0
    g=0
    b=0
    endif
    endif
    
    
    return vma coloured (r,g,b)style(line,2)as "Variable Moving Average"
    
    #31348 quote
    supertiti
    Participant
    Master

    Hola Miguel Angel

     

    Aqui tienes el codigo, Nicolas lo ha hecho hace poco

    un saludo

    // VMA PRC_Variable Moving Average 14.12.2016
    //Nicolas @ www.prorealcode.com Sharing ProRealTime knowledge
    //converted and adapted from Pinescript version
    
    src=customclose
    if barindex>l then
    k = 1.0/l
    pdm = max((src - src[1]), 0)
    mdm = max((src[1] - src), 0)
    pdmS = ((1 - k)*(pdmS[1]) + k*pdm)
    mdmS = ((1 - k)*(mdmS[1]) + k*mdm)
    s = pdmS + mdmS
    pdi = pdmS/s
    mdi = mdmS/s
    pdiS = ((1 - k)*(pdiS[1]) + k*pdi)
    mdiS = ((1 - k)*(mdiS[1]) + k*mdi)
    d = abs(pdiS - mdiS)
    s1 = pdiS + mdiS
    iS = ((1 - k)*(iS[1]) + k*d/s1)
    hhv = highest[l](iS)
    llv = lowest[l](iS)
    d1 = hhv - llv
    vI = (iS - llv)/d1
    vma = (1 - k*vI)*(vma[1]) + k*vI*src
    endif
    
    
    RETURN SRC as " CC " , VMA as " VMA " 
    
    // Variables :
    // l = 6 
    
    

    // A VMA is an EMA that is able to regulate its smoothing percentage based on market inconstancy automatically. Its sensitivity grows by providing more weight to the ongoing data as it generates a better signal indicator for short and long-term markets.

     

    // The majority of ways for measuring Moving Averages cannot compensate for sideways moving prices versus trending markets and often generate a lot of false signals. Longer-term moving averages are slow to react to reversals in trend when prices move up and down over a long period of time. A Variable Moving Average regulates its sensitivity and lets it function better in any market conditions by using automatic regulation of the smoothing constant.

     

    // The Variable Moving Average is also known as the VIDYA Indicator. But this version is a modified concept of the VIDYA.

     

    // The Variable Moving Average was developed by Tushar S. Chande and first presented in his March, 1992 article in Technical Analysis of Stocks & Commodities magazine, in which a standard deviation was used as the Volatility Index. In his October, 1995 article in the same magazine, Chande modified the VIDYA to use his own Chande Momentum Oscillator (CMO) as the Volatility Index, the VMA code below is the result of this modification.

    #31350 quote
    supertiti
    Participant
    Master

    Aqui tienes la VMA de BBVA

    #31358 quote
    bolsatrilera
    Participant
    Master

    Muchas gracias Supertiti, no sabía que estaba por aquí.Ahora solo me queda delimitar los colores de la media como en el original:

    verde=alcista

    rojo=bajista

    azul y negro=congestión

    REM VARIABLE MOVING AVERAGE
    //código original de LazyBear para la plataforma Tradingview
    //media exponencial desarrollada por Tushar S. Chande
    //adaptación para la plataforma Prorealtime v10.3
    //en el cuadro de variables nz= tipo Boleano
    
    
    src=close
    I=6
    if barindex>I then
    K=1.0/I
    pdm=max((src-src[1]),0)
    mdm=max((src[1]-src),0)
    pdmS=((1-K)*(pdmS[nz]) + K*pdm)
    mdmS=((1-K)*(mdmS[nz]) + K*mdm)
    s=pdmS + mdmS
    pdi=pdmS/s
    mdi=mdmS/s
    pdis=((1-K)*(pdis[nz])+ K*pdi)
    mdis=((1-K)*(mdis[nz])+ K*mdi)
    d=abs(pdis - mdis)
    s1=pdis+mdis
    IS=((1-K)*(IS[nz])+K*d/s1)
    hhv=highest[I](IS)
    llv=lowest[I](IS)
    d1=hhv-llv
    v1=(IS-llv)/d1
    vma=(1-K*v1)*(vma[nz])+K*v1*src
    
    if vma then
    if vma >vma[1] then
    r=0
    g=255
    b=0
    endif
    
    if vma<vma[1] then
    r=255
    g=0
    b=0
    endif
    
    if vma=vma[1] then
    r=0
    g=0
    b=255
    else
    r=0
    g=0
    b=0
    endif
    endif
    endif
    
    
    return vma coloured (r,g,b)style(line,2)as "Variable Moving Average"
    
    #31385 quote
    supertiti
    Participant
    Master

    variable : l = 6  como length  , no es una i !

    un saludo

    #31439 quote
    bolsatrilera
    Participant
    Master

    Buenas tardes. Supertiti es lo mismo l = 6 que i=6 lo importante es designar =6.

    Creo que lo he conseguido.

    A

    REM VARIABLE MOVING AVERAGE
    //código original de LazyBear para la plataforma Tradingview
    //media exponencial desarrollada por Tushar S. Chande
    //adaptación para la plataforma Prorealtime v10.3
    //en el cuadro de variables nz= tipo Boleano
    
    
    src=close
    l = 6
    if barindex>l then
    K=1.0/l
    pdm=max((src-src[1]),0)
    mdm=max((src[1]-src),0)
    pdmS=((1-K)*(pdmS[nz]) + K*pdm)
    mdmS=((1-K)*(mdmS[nz]) + K*mdm)
    s=pdmS + mdmS
    pdi=pdmS/s
    mdi=mdmS/s
    pdis=((1-K)*(pdis[nz])+ K*pdi)
    mdis=((1-K)*(mdis[nz])+ K*mdi)
    d=abs(pdis - mdis)
    s1=pdis+mdis
    IS=((1-K)*(IS[nz])+K*d/s1)
    hhv=highest[l](IS)
    llv=lowest[l](IS)
    d1=hhv-llv
    v1=(IS-llv)/d1
    vma=(1-K*v1)*(vma[nz])+K*v1*src
    endif
    
    
    if vma >vma[1] then
    r=0
    g=153
    b=0
    elsif vma<vma[1] then
    r=255
    g=0
    b=0
    elsif vma=vma[1] then
    r=0
    g=0
    b=255
    endif
    
    
    
    
    
    return vma coloured (r,g,b)style(line,2)as "Variable Moving Average"
    

    ntes me equivoqué con el color negro.La media tiene tres colores:

    verde=alcista

    rojo=bajista

    azul=congestión

    #31494 quote
    supertiti
    Participant
    Master

    Enhorabuena asi fuciona bien la VMA !

    Dime que es la variable ” nz ” ?

    ademas podemos poner la variable ” L ” en variable externa para cambiarla porque a veces la vma no funcina y tenemos que subir o bajar la “L”

    buen domingo de Ramos

    #31497 quote
    supertiti
    Participant
    Master
    // VMA BOLSA trilera  VARIABLE MOVING AVERAGE
    //código original de LazyBear para la plataforma Tradingview
    //media exponencial desarrollada por Tushar S. Chande
    //adaptación para la plataforma Prorealtime v10.3
    
    src=close
    // l = 6
    if barindex>l then
    K=1.0/l
    pdm=max((src-src[1]),0)
    mdm=max((src[1]-src),0)
    pdmS=((1-K)*(pdmS[nz]) + K*pdm)
    mdmS=((1-K)*(mdmS[nz]) + K*mdm)
    s=pdmS + mdmS
    pdi=pdmS/s
    mdi=mdmS/s
    pdis=((1-K)*(pdis[nz])+ K*pdi)
    mdis=((1-K)*(mdis[nz])+ K*mdi)
    d=abs(pdis - mdis)
    s1=pdis+mdis
    IS=((1-K)*(IS[nz])+K*d/s1)
    hhv=highest[l](IS)
    llv=lowest[l](IS)
    d1=hhv-llv
    v1=(IS-llv)/d1
    vma=(1-K*v1)*(vma[nz])+K*v1*src
    endif
    
    if vma >vma[1] then
    r=255 //0
    g=127  //153
    b=0
    elsif vma<vma[1] then
    r=255
    g=0
    b=0
    elsif vma=vma[1] then
    r=255 //0
    g=255 //0
    b=0  // 255
    endif
    
    VMAH = VMA + coeff
    VMAB = VMA - coeff
    Return customclose as " customclose " , vma coloured (r,g,b)style(line,5)as "Variable Moving Average" , VMAH coloured (r,g,b)style(line,2)as " VMAH " , VMAB coloured (r,g,b)style(line,2) as " VMAB "
    
    // Variables :
    // l = 6 
    // nz= tipo Boleano
    // coeff = 1 decimal
    
    #31500 quote
    bolsatrilera
    Participant
    Master

    En el cuadro de variables , poner nz y elegir tipo Boleano.Acabo de publicar el código en un blog que tengo .Cualquier duda se lo mando en archivo itf listo para incorporar a su plataforma .

    Un saludo grande supertiti ,ahora me dedico a disfrutar de la Semana Santa en mi tierra, Málaga.

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

Variable Moving Average


ProBuilder: Indicadores y Herramientas

New Reply
Author
Summary

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

Topic Details
Forum: ProBuilder: Indicadores y Herramientas
Language: Spanish
Started: 04/07/2017
Status: Active
Attachments: 4 files
Logo Logo
Loading...