Hi,
I hope someone can help. I’m trying to create a indicator which alerts on the 1hr time-frame for bullish or bearish cross over of the previous days close. My current code is:
res=0
pdc=dclose(1)
Timeframe(1 hour)
a1=close crosses over pdc
long=a1[1]
Timeframe(1 hour)
b1=close crosses under pdc
short=b1[1]
if long then
res=1
elsif short then
res=-1
endif
screener [(long) or (short)] (res as "direction")
I need help to ensure it only triggers based on the previous hour. The results seem random when executed against the currencies market. Can someone help?
You are over complicated the code, I think it could work like this, and running it on the 1-hour timeframe. Dclose is a constant that you can use in any timeframe.
res=0
a1=close crosses over dclose(1)
b1=close crosses under dclose(1)
long=a1[1]
short=b1[1]
if long then
res=1
elsif short then
res=-1
endif
screener [res<>0] (res as "direction")