SMA50 is above SMA200 but for less than 3 weeks

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

    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

    #217704 quote
    JS
    Participant
    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)…

    #217705 quote
    benkunz
    Participant
    New
    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
    #217706 quote
    JS
    Participant
    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")
    
    Nicolas thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

SMA50 is above SMA200 but for less than 3 weeks


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
benkunz @benkunz Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by JS
2 years, 8 months ago.

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