Encontré este curioso indicador en la plataforma Tradingview creado por el gran Lazy Bear: https://es.tradingview.com/script/HFGx4ote-Indicator-Weis-Wave-Volume-LazyBear/
Tengo esta adaptación para Prorealtime y me gustaría que alguién le echara un vistazo para corroborar si el código es correcto o contiene algún fallo…
REM WEIS WAVE VOLUME
// @author LazyBear
// List of all indicators Lazy Bear: https://www.tradingview.com/v/4IneGo8h/
//adaptación para Prorealtime por bolsatrilera
//En cuadro de variables, showDistributionBelowZero=falso, tipo=boleano
//En cuadro de variables, nz =falso,tipo=boleano
trendDetectionLength=2
if close>close[1] then
mov=1
elsif close<close[1] then
mov=-1
else
mov=0
endif
if mov <>0 and mov <> mov[1] then
trend=mov
else
trend=trend[nz]
endif
rising=abs(close-close[1])>abs(close-close[trendDetectionLength])
falling=abs(close-close[1]<abs(close-close[trendDetectionLength]))
if rising or falling then
isTrending= rising or falling
endif
if trend <> wave[nz] and isTrending then
wave=trend
else
wave=wave[nz]
endif
if wave=wave[1] then
vol=vol[nz]+volume
else
vol=volume
endif
if wave=1 then
up=vol
else
up=0
endif
if showDistributionBellowZero then
if wave=1 then
dn=0
endif
endif
if wave=-1 then
dn=-vol
else
dn=vol
endif
if wave=1 then
dn=0
else
dn=vol
endif
return up coloured (0,128,0)style(histogram)as "up",dn coloured(255,0,0)style(histogram)as "dn"
“nz” no es una variable en el lenguaje pinescript, es una instrucción para asegurar que una variable no sea igual a cero. Debería definirlo primero en su código antes de usar “nz” como variable.
está definido Nicolas, se pone nz en el cuadro de variables y se elige tipo=boleano
Oh ya veo, pero esa no es la forma en que debería haberlo codificado 🙂
Puede eliminar y reemplazar todo su [nz] con [1] en este caso, para estar perfectamente de acuerdo con el código original.
¿Por qué no agregar esto también en nuestra biblioteca? ¡Otra buena adición! Gracias.
lo que usted me dice es algo como esto ,¿ no es así Nicolas?
REM WEIS WAVE VOLUME
// @author LazyBear
// List of all indicators Lazy Bear: https://www.tradingview.com/v/4IneGo8h/
//adaptación para Prorealtime por bolsatrilera
trendDetectionLength=2
if close>close[1] then
mov=1
elsif close<close[1] then
mov=-1
else
mov=0
endif
if mov <>0 and mov <> mov[1] then
trend=mov
else
trend=trend[0]
endif
rising=abs(close-close[1])>abs(close-close[trendDetectionLength])
falling=abs(close-close[1]<abs(close-close[trendDetectionLength]))
if rising or falling then
isTrending= rising or falling
endif
if trend <> wave[1] and isTrending then
wave=trend
else
wave=wave[0]
endif
if wave=wave[1] then
vol=vol[0]+volume
else
vol=volume
endif
if wave=1 then
up=vol
else
up=0
endif
if 0 then
if wave=1 then
dn=0
endif
endif
if wave=-1 then
dn=-vol
else
dn=vol
endif
if wave=1 then
dn=0
else
dn=vol
endif
return up coloured (0,128,0)style(histogram)as "up",dn coloured(255,0,0)style(histogram)as "dn"