Buenos días.
En base al screener de TRIN creado por Roberto:
// Arms Index (TRIN)
//
// also named Short-Term Trading Index (TRIN)
//
//
Periods = 20
BullBAR = close > close[1]
BearBAR = close < close[1]
AdvBAR= 1
AdvVOL= 1
DecBAR= 1
DecVOL= 1
myTrin= 0
IF BarIndex >= Periods THEN
FOR i = 0 TO Periods
IF BullBAR[i] THEN
AdvBAR = AdvBAR + 1
AdvVOL = AdvVOL + volume[i]
ELSIF BearBAR[i] THEN
DecBAR = DecBAR + 1
DecVOL = DecVOL + volume[i]
ENDIF
NEXT
IndexBAR = AdvBAR / DecBAR
IndexVOL = AdvVOL / DecVOL
myTrin= IndexBAR / IndexVOL
ENDIF
Signal = 0
IF myTrin <= 0.5 THEN
Signal = 1
ELSIF myTrin >= 1.5 THEN
Signal = 2
ENDIF
SCREENER[Signal](Signal AS “1=↑,2=↓”)
he tratado de separarlo para valores ascendentes (1=↑) por un lado y descendentes por otros(2=↓) y además, quisiera que dentro de los ascendentes, cuyo myTrin<= 0.5, pudiera fijar
un criterio adicional que me orden los valores encontrados dentro de un rango. Por ejemplo: Cond2=mytrin>0.2 and mytrin<0.4
El screener alcista me saldría algo así:
// Arms Index (TRIN)
//
// also named Short-Term Trading Index (TRIN)
//
// https://corporatefinanceinstitute.com/resources/equities/arms-index-trin/
//
Periods = 20
BullBAR = close > close[1]
BearBAR = close < close[1]
AdvBAR = 1
AdvVOL = 1
DecBAR = 1
DecVOL = 1
myTrin = 0
IF BarIndex >= Periods THEN
FOR i = 0 TO Periods
IF BullBAR[i] THEN
AdvBAR = AdvBAR + 1
AdvVOL = AdvVOL + volume[i]
ELSIF BearBAR[i] THEN
DecBAR = DecBAR + 1
DecVOL = DecVOL + volume[i]
ENDIF
NEXT
IndexBAR = AdvBAR / DecBAR
IndexVOL = AdvVOL / DecVOL
myTrin = IndexBAR / IndexVOL
ENDIF
Signal = 0
IF myTrin<=0.5 THEN
Signal=1
ENDIF
Cond1=close>4 and volume>50000
//Criterio de clasificación
Cond2=myTrin
Criteria=cond2<0.4 and cond2>0.2
SCREENER[Signal and cond1 and cond2](criteria)
El problema que tengo es que me salen valores que no cumplen que el trin sea >0.2 y <0.4 (por ejemplo me sale un trin de 1.81, etc).
¿Cómo se puede arreglar?
Gracias y un saludo.