Hi.
If I have the following code, how could I include in the condition that the EMA crossover happens within the previous 3 days if it’s part of a larger scan with more conditions? As it stands this code could give results that have just crossed over or those that crossed over 6 month previous and are still climbing.
In essence, sine EMA’s are lagging indicators I’d like to screen for crossovers that happened, say, within the last week or so.
timeframe(Daily)
EMA20 = ExponentialAverage[20] (close)
EMA100 = ExponentialAverage[100] (close)
Condition = (EMA20 > EMA100)
SCREENER[Condition]
Maybe an event variable will help:
If ema1 crosses over ema2 then Event = 1 Else event = 0 Endif
You can then screen for event [1]=1
The line breaks have got lost somehow in the code.
If ema1 crosses over ema2 then
Event = 1
Else
event = 0
Endif
Thanks Derek. I’ll give it a try…
So what you want to do is to test if a crossover has happened in the past without having see it in real time? Am I right?
Yes – to see which stocks made the move in the last 5 days for instance…
I have coded something similar here, I think:
screen condition c within last x days