Variable Moving Average
Forums › ProRealTime foro Español › Soporte ProBuilder › Variable Moving Average
- This topic has 8 replies, 2 voices, and was last updated 7 years ago by bolsatrilera.
-
-
04/07/2017 at 9:44 AM #31331
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?
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354REM 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 Boleanosrc=closeI=6K=1.0/Ipdm=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 + mdmSpdi=pdmS/smdi=mdmS/spdis=((1-K)*(pdis[nz])+ K*pdi)mdis=((1-K)*(mdis[nz])+ K*mdi)d=abs(pdis - mdis)s1=pdis+mdisIS=((1-K)*(IS[nz])+K*d/s1)hhv=highest[I](IS)llv=lowest[I](IS)d1=hhv-llvv1=(IS-llv)/d1vma=(1-K*v1)*(vma[nz])+K*v1*srcif vma thenif vma >vma[1] thenr=0g=255b=0endifif vma<vma[1] thenr=255g=0b=0endifif vma=vma[1] thenr=0g=0b=255elser=0g=0b=0endifendifreturn vma coloured (r,g,b)style(line,2)as "Variable Moving Average"04/07/2017 at 11:24 AM #31348Hola Miguel Angel
Aqui tienes el codigo, Nicolas lo ha hecho hace poco
un saludo
12345678910111213141516171819202122232425262728293031// VMA PRC_Variable Moving Average 14.12.2016//Nicolas @ www.prorealcode.com Sharing ProRealTime knowledge//converted and adapted from Pinescript versionsrc=customcloseif barindex>l thenk = 1.0/lpdm = 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 + mdmSpdi = pdmS/smdi = mdmS/spdiS = ((1 - k)*(pdiS[1]) + k*pdi)mdiS = ((1 - k)*(mdiS[1]) + k*mdi)d = abs(pdiS - mdiS)s1 = pdiS + mdiSiS = ((1 - k)*(iS[1]) + k*d/s1)hhv = highest[l](iS)llv = lowest[l](iS)d1 = hhv - llvvI = (iS - llv)/d1vma = (1 - k*vI)*(vma[1]) + k*vI*srcendifRETURN 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.
04/07/2017 at 11:30 AM #3135004/07/2017 at 11:58 AM #31358Muchas 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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556REM 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 Boleanosrc=closeI=6if barindex>I thenK=1.0/Ipdm=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 + mdmSpdi=pdmS/smdi=mdmS/spdis=((1-K)*(pdis[nz])+ K*pdi)mdis=((1-K)*(mdis[nz])+ K*mdi)d=abs(pdis - mdis)s1=pdis+mdisIS=((1-K)*(IS[nz])+K*d/s1)hhv=highest[I](IS)llv=lowest[I](IS)d1=hhv-llvv1=(IS-llv)/d1vma=(1-K*v1)*(vma[nz])+K*v1*srcif vma thenif vma >vma[1] thenr=0g=255b=0endifif vma<vma[1] thenr=255g=0b=0endifif vma=vma[1] thenr=0g=0b=255elser=0g=0b=0endifendifendifreturn vma coloured (r,g,b)style(line,2)as "Variable Moving Average"04/07/2017 at 2:32 PM #3138504/08/2017 at 4:59 PM #31439Buenas tardes. Supertiti es lo mismo l = 6 que i=6 lo importante es designar =6.
Creo que lo he conseguido.
A
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950REM 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 Boleanosrc=closel = 6if barindex>l thenK=1.0/lpdm=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 + mdmSpdi=pdmS/smdi=mdmS/spdis=((1-K)*(pdis[nz])+ K*pdi)mdis=((1-K)*(mdis[nz])+ K*mdi)d=abs(pdis - mdis)s1=pdis+mdisIS=((1-K)*(IS[nz])+K*d/s1)hhv=highest[l](IS)llv=lowest[l](IS)d1=hhv-llvv1=(IS-llv)/d1vma=(1-K*v1)*(vma[nz])+K*v1*srcendifif vma >vma[1] thenr=0g=153b=0elsif vma<vma[1] thenr=255g=0b=0elsif vma=vma[1] thenr=0g=0b=255endifreturn 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
04/09/2017 at 11:49 AM #31494Enhorabuena 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
04/09/2017 at 12:10 PM #314971234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950// 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.3src=close// l = 6if barindex>l thenK=1.0/lpdm=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 + mdmSpdi=pdmS/smdi=mdmS/spdis=((1-K)*(pdis[nz])+ K*pdi)mdis=((1-K)*(mdis[nz])+ K*mdi)d=abs(pdis - mdis)s1=pdis+mdisIS=((1-K)*(IS[nz])+K*d/s1)hhv=highest[l](IS)llv=lowest[l](IS)d1=hhv-llvv1=(IS-llv)/d1vma=(1-K*v1)*(vma[nz])+K*v1*srcendifif vma >vma[1] thenr=255 //0g=127 //153b=0elsif vma<vma[1] thenr=255g=0b=0elsif vma=vma[1] thenr=255 //0g=255 //0b=0 // 255endifVMAH = VMA + coeffVMAB = VMA - coeffReturn 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 decimal04/09/2017 at 12:14 PM #31500En 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.
-
AuthorPosts