strange behavior with SMA crossing

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #220511 quote
    benkunz
    Participant
    New

    Hi,

    here is my screener :

    TIMEFRAME(daily)
    SMA50 = average[50](close)
    SMA200 = average[200](close)
    
    C1=SMA50>SMA200
    
    Crossing=1000
    N=50
    For i=0 to N-1
    If SMA50[i]<SMA200[i] then
    Crossing=i
    Break
    EndIf
    Next
    // i want SMA50 above SMA200in the last 5 days
    C2=Crossing<5
    
    Screener[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

    2023-09-07-15_46_28-VIRTUS-CONVERTIBLE-INC.-FUND-Daily-3.27-0.91-6-Sep-2023.jpg 2023-09-07-15_46_28-VIRTUS-CONVERTIBLE-INC.-FUND-Daily-3.27-0.91-6-Sep-2023.jpg 2023-09-07-15_46_02-VIRTUS-CONVERTIBLE-INC.-FUND-Daily-3.27-0.91-6-Sep-2023.jpg 2023-09-07-15_46_02-VIRTUS-CONVERTIBLE-INC.-FUND-Daily-3.27-0.91-6-Sep-2023.jpg
    #220538 quote
    robertogozzi
    Moderator
    Master

    This will do:

    TIMEFRAME(daily)
    SMA50  = average[50](close)
    SMA200 = average[200](close)
    c1     = Sma50[5] < Sma200[5]
    c2     = (summation[5](Sma50 > Sma200) = 5)
    Screener[C1 and C2]
    #220599 quote
    benkunz
    Participant
    New

    hi,

    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 ?

    Capture-decran-2023-09-08-a-20.51.49.jpg Capture-decran-2023-09-08-a-20.51.49.jpg
    #220601 quote
    JS
    Participant
    Veteran

    Hi,

    Try this one:

    TIMEFRAME(daily)
    SMA50  = average[50](close)
    SMA200 = average[200](close)
    xCrossing=0
    For i=1 to 5
    If SMA50[i] crosses over SMA200[i] then
    xCrossing=i
    Break
    EndIf
    Next
    C1=xCrossing=1 or xCrossing=2 or xCrossing=3 or xCrossing=4 or xCrossing=5
    
    Screener[C1](xCrossing as "DaysBackCrossing")
    benkunz thanked this post
    Scherm­afbeelding-2023-09-08-om-21.28.21.png Scherm­afbeelding-2023-09-08-om-21.28.21.png
    #220606 quote
    robertogozzi
    Moderator
    Master

    No, my script checks only the last 5 bars, the 6th bar, bar 5, is checked not to be above.’

    #220660 quote
    benkunz
    Participant
    New

    Hi,

    Try this one:

    works great !

    JS thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

strange behavior with SMA crossing


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
benkunz @benkunz Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by benkunz
2 years, 6 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 09/07/2023
Status: Active
Attachments: 4 files
Logo Logo
Loading...