Hello, I’m trying to find which stock had its sma3 crossing sma200 5 days ago. I came up with this simple code
————–
sma3 = Average[3,0](close)
sma200 = Average[200,0](close)
offset=5
crossedOver=0
if ( (sma3[offset] crosses over sma200[offset]) ) then
crossedOver=1
endif
SCREENER [crossedOver]
———–
However, the stocks that are returned have their sma’s not crossed 5 days ago. Am I doing something wrong ?
Another question, I’ve tried to make the offset incremented in a WHILE loop. I’m sure that the values are >0 and < 100, but I still got an error that my offset is negative or >250.
Is the offset supporting a variable incremented in a WHILE loop ?
Thanks in advance
Patrick