Hi,
I’d like to know how I could get the value of SMA200 of 20 days ago ?
the goal is to detect if the SMA200 has been going up over the last 20 days
thanks
There you go:
Sma200 = average[200,0](close)
UP = Sma200 > Sma200[20]
SCREENER[UP](Sma200 AS "Sma200")
I’m confused…
here is my original screener :
TIMEFRAME(daily)
SMA50 = average[50](close)
SMA200 = average[200](close)
NoDaysMaxForCrossing = 20
xCrossing=0
For i=1 to NoDaysMaxForCrossing
If SMA50[i] crosses over SMA200[i] then
xCrossing=i
Break
EndIf
Next
C1=xCrossing>=1 and xCrossing<=NoDaysMaxForCrossing
SMA5enBaisse = close[5] > close[3] AND close[3] > close
PrixAuDessusSMAs = close > SMA200 AND close > SMA50
// DEFAULT CONDITIONS
Timeframe(Yearly)
minimumAge = barindex>=3
TimeFrame(Monthly)
p1 = lowest[36](close)>=3
TimeFrame(Daily)
p2 = (close<= 1000)
v1 = Average[50](Volume) >= 50000
defaultConditons = p1 AND p2 AND v1 and minimumAge
// DEFAULT CONDITIONS
Screener[C1 and SMA5enBaisse and PrixAuDessusSMAs and defaultConditons](xCrossing as "DaysBackCrossing")
If I run this screener on the “US NSYE Actions”, it returns 8 stocks including the one on the screenshot. On this screenshot, we can see that the SMA200 100 days ago was below today’s SMA.
But if I add a new criteria based on what you told me, I get 0 result. I don’t get. What did I do wrong ? any idea ?
TIMEFRAME(daily)
SMA50 = average[50](close)
SMA200 = average[200](close)
NoDaysMaxForCrossing = 20
xCrossing=0
For i=1 to NoDaysMaxForCrossing
If SMA50[i] crosses over SMA200[i] then
xCrossing=i
Break
EndIf
Next
C1=xCrossing>=1 and xCrossing<=NoDaysMaxForCrossing
SMA5enBaisse = close[5] > close[3] AND close[3] > close
PrixAuDessusSMAs = close > SMA200 AND close > SMA50
SMA200goingUp = SMA200 > SMA200[100]
// DEFAULT CONDITIONS
Timeframe(Yearly)
minimumAge = barindex>=3
TimeFrame(Monthly)
p1 = lowest[36](close)>=3
TimeFrame(Daily)
p2 = (close<= 1000)
v1 = Average[50](Volume) >= 50000
defaultConditons = p1 AND p2 AND v1 and minimumAge
// DEFAULT CONDITIONS
Screener[C1 and SMA5enBaisse and PrixAuDessusSMAs and SMA200goingUp and defaultConditons](xCrossing as "DaysBackCrossing")
SMA200goingUp = SMA200 > SMA200[100] is not allowed in screeners as 200+100 exceeds the 256-bar limit with IG. Only the premium version from PRT supports a 1024-bar limit.
To make sure your conditions are all correct, analyze them separately, esch one of them, then combine them.
Can you please elaborate the « analyze them separately, esch one of them, then combine them » ?
Switching the timeframe with « timeframe(weekly) » might be easier ?
All you need is to use test one condition at a time:
- Screener[C1]
- Screener[SMA5enBaisse]
- Screener[PrixAuDessusSMAs]
- Screener[SMA200goingUp]
- Screener[defaultConditons]
when you are confident they all work, you can combine them in a single line.
you lost me… to combine them in a single line, you’d do Screener[C1 AND C2 AND C3 ] ?
and how would you do the testing one condition at a time ?
One condition at a time like my example in my last post.
You start with the first one, when it’s ok thrn you replace it with the second one (or even better, you add it to the first one), eyc… until all conditions return what you expect.
Then you may combine them as you want, like you did in line 30 or 33.