Price crosses over SMA

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

    Hi,
    I’m looking for a way to detect stocks for which the price crossed over the SMA50 in the last 10 days.
    thanks

    #230478 quote
    Iván González
    Moderator
    Master

    Hello Here you have:

    sma = average[50](close)
    
    n = barssince(close crosses over sma)
    screener[n<10]

    If you also want the price to be above the average, you just have to change the last line with this one: screener[n<10 and close > sma]

    #230480 quote
    robertogozzi
    Moderator
    Master

    There you go:

    Sma50 = average[50,0](close)
    c1    = summation[10](close CROSSES OVER Sma50)
    c2    = close > Sma50
    c3    = high <> low
    Cond  = c1 AND c2 AND c3
    SCREENER[Cond]
    Iván González and benkunz thanked this post
    #230481 quote
    robertogozzi
    Moderator
    Master

    Two is better than one! 🙂

    #230482 quote
    benkunz
    Participant
    New

    great, thanks.
    I had never heard about this barssince function.

    and what if I also want to make sure the price did not go below SMA50 after it crossed over the SMA ?

    #230491 quote
    Iván González
    Moderator
    Master

    Hello again, following the same logic as before you can program the following:

    sma = average[50](close)
    
    n = barssince(close crosses over sma)
    m = barssince(close crosses under sma)
    
    screener[n<10 and m>=10]
    #230503 quote
    benkunz
    Participant
    New

    it is starting to drive me crazy 🙂

    SMA200 = average[200](close)
    n200 = barssince(close crosses over SMA200)
    priceCrossedSMA200 = n200 < 3
    priceAboveSMA200 = low > SMA200
    CondSMA200 = (priceCrossedSMA200 and priceAboveSMA200)
    
    SCREENER[CondSMA200] (volume)

    here is the script I wrote based on your ideas. It includes stocks where the price did not cross the SMA200 in the last 3 days. I dont get why. Any idea ?

    #230508 quote
    Iván González
    Moderator
    Master

    It works, but to avoid those stocks that have never crossed the sma200 we can add this n200>=0:

    SMA200 = average[200](close)
    n200 = barssince(close crosses over SMA200)
    priceCrossedSMA200 = n200 < 3 and n200 >= 0
    priceAboveSMA200 = low > SMA200
    CondSMA200 = (priceCrossedSMA200 and priceAboveSMA200)
    
    screener[CondSMA200]
    benkunz thanked this post
    #230524 quote
    benkunz
    Participant
    New

    thanks Ivan, appreciate it

    #230525 quote
    benkunz
    Participant
    New

    How would you deal with this screenshot ? where the price came close from above to the SMA200, but did not cross it. Then price went back up. I’d like to include those patterns in the detection

    Capture-decran-2024-03-26-a-21.56.15.jpg Capture-decran-2024-03-26-a-21.56.15.jpg
    #230563 quote
    Iván González
    Moderator
    Master

    Hello
    I would create a line parallel to the sma200 at X distance. From there I would proceed the same as in previous screener but now the reference average would be the parallel to the sma.
    To ensure that the price comes from crossing down the sma200 offset without having crossed down the sma200 then we can control the barindex of each situation.

     

    sma = average[50](close)
    smadist = sma + 2/100*sma
    
    n = barssince(close crosses over smadist)
    
    if close crosses under sma then
    $crossSMA[0]=barindex 
    endif
    if close crosses under smadist then
    $crossSMAdist[0]=barindex
    endif
    
    setup = n>=0 and n<5 and $crossSMA[0]<$crossSMAdist[0] and close > smadist
    screener[setup]
    #232888 quote
    IronyCheese
    Participant
    New

    Did you investigate how to rank these stocks by the number of days they have spent over their SMA200 or something else?

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

Price crosses over SMA


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
benkunz @benkunz Participant
Summary

This topic contains 11 replies,
has 4 voices, and was last updated by IronyCheese
1 year, 9 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 03/26/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...