Hi,
here is my code :
TIMEFRAME(daily)
SMA50 = average[50](close)
SMA200 = average[200](close)
c1 = SMA50 > SMA200
SCREENER [c1]
How would you do to only report stocks for which the SMA50 is above SMA200 but for less than 3 weeks ? the idea is to get stocks that recently started to go up
another question but related to the 1st one :
today is July 15th. To get the average between July 1st and July 15th, I would do that : average[15](close). Now, if I want the average between July 1st and July 10th, how should I do ?
regards
JSParticipant
Veteran
Hi,
You can always use the “Summation” function…
C2=Summation[15](SMA50>SMA200)=15
What it says here is: count the days over the last 15 days where the SMA50 is above the SMA200 and this number of days must be equal to 15.
The number of (trading) days between the 1st and the 15th of July is equal to 10, so Average[10](Close)…
The number of (trading) days between the 1st and the 10th of July is equal to 5 or 6 so Average[5](Close)…
thanks for the idea, but this won’t do it. What I want is the SMA50 to be above SMA200 for less than 3 weeks. So, 3 weeks ago (at the most), I want SMA200 to be above SMA50
JSParticipant
Veteran
Hi,
That’s right, that wasn’t foolproof…
You can add an extra condition that calculates the day of the crossing between SMA50 & SMA200…
TIMEFRAME(daily)
SMA50 = average[50](close)
SMA200 = average[200](close)
C1=Summation[15](SMA50>SMA200)=15
N=50
For i=0 to N-1
If SMA50[i]<SMA200[i] then
Crossing=i
Break
EndIf
Next
C2=Crossing>15 and Crossing<20
Screener[C1 and C2](Crossing as "DaysBackCrossing")