strange behavior with SMA crossing
Forums › ProRealTime English forum › ProScreener support › strange behavior with SMA crossing
- This topic has 5 replies, 3 voices, and was last updated 1 year ago by benkunz.
-
-
09/07/2023 at 2:51 PM #220511
Hi,
here is my screener :
123456789101112131415161718TIMEFRAME(daily)SMA50 = average[50](close)SMA200 = average[200](close)C1=SMA50>SMA200Crossing=1000N=50For i=0 to N-1If SMA50[i]<SMA200[i] thenCrossing=iBreakEndIfNext// i want SMA50 above SMA200in the last 5 daysC2=Crossing<5Screener[C1 and C2](Crossing as "DaysBackCrossing")Basically, I want to get the stocks whose SMA50 went above SMA200 in the last 5 days.
Most of my results are correct, but for some, i notice the SMA50 being below SMA200. Any idea why ? I’ll attach 2 screenshots for the same stock that was reported by the screener. one screenshot has historical data adjusted for dividends, and the other without the adjustment. In both cases, SMA200 is above SMA50.
thanks
09/08/2023 at 8:17 AM #220538This will do:
123456TIMEFRAME(daily)SMA50 = average[50](close)SMA200 = average[200](close)c1 = Sma50[5] < Sma200[5]c2 = (summation[5](Sma50 > Sma200) = 5)Screener[C1 and C2]09/08/2023 at 7:53 PM #220599hi,
it seems that this script returns the stocks where SMA50 went above SMA200 5 days ago, and not in the last 5 days, doesn’t it ?
and this script returns 4 results on the NYSE. I’m attaching one of the 4 results where SMA50 is below SAM200. So it also seems to be doing the same weird thing as my original script. any idea why ?
09/08/2023 at 8:28 PM #220601Hi,
Try this one:
SMA Crossing12345678910111213TIMEFRAME(daily)SMA50 = average[50](close)SMA200 = average[200](close)xCrossing=0For i=1 to 5If SMA50[i] crosses over SMA200[i] thenxCrossing=iBreakEndIfNextC1=xCrossing=1 or xCrossing=2 or xCrossing=3 or xCrossing=4 or xCrossing=5Screener[C1](xCrossing as "DaysBackCrossing")1 user thanked author for this post.
09/08/2023 at 8:51 PM #220606No, my script checks only the last 5 bars, the 6th bar, bar 5, is checked not to be above.’
09/10/2023 at 7:10 PM #220660Hi,
Try this one:
SMA Crossing12345678910111213TIMEFRAME(daily)SMA50 = average[50](close)SMA200 = average[200](close)xCrossing=0For i=1 to 5If SMA50[i] crosses over SMA200[i] thenxCrossing=iBreakEndIfNextC1=xCrossing=1 or xCrossing=2 or xCrossing=3 or xCrossing=4 or xCrossing=5Screener[C1](xCrossing as “DaysBackCrossing”)works great !
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on