SMA50 is above SMA200 but for less than 3 weeks
- This topic has 3 replies, 2 voices, and was last updated 1 year ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
Forums › ProRealTime English forum › ProScreener support › SMA50 is above SMA200 but for less than 3 weeks
Hi,
here is my code :
1 2 3 4 5 6 7 |
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
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)…
Hi,
That’s right, that wasn’t foolproof…
You can add an extra condition that calculates the day of the crossing between SMA50 & SMA200…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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") |