PRC MACD screener with conditions

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #248455 quote
    segie
    Participant
    Senior

     

    // — settings
    short = 12
    long = 26
    signal = 9
    // — end of settings
    EMAshort1 = exponentialaverage[short](close)
    EMAshort2 = exponentialaverage[short](EMAshort1)
    DifferenceShort = EMAshort1 – EMAshort2
    ZeroLagShort = EMAshort1 + DifferenceShort
    flag=0
    
    EMAlong1 = exponentialaverage[long](close)
    EMAlong2 = exponentialaverage[long](EMAlong1)
    DifferenceLong = EMAlong1 – EMAlong2
    ZeroLagLong = EMAlong1 + DifferenceLong
    
    ZeroLagMACD = ZeroLagShort – ZeroLagLong
    
    signal1=ExponentialAverage[signal](ZEROLAGMACD)
    signal2=ExponentialAverage[signal](signal1)
    DIFFERENCE2=signal1-signal2
    SignalMACD=signal1+DIFFERENCE2
    if zerolagMACD crosses over signalMACD then
    flag=1
    endif
    if zerolagMACD crosses under signalMACD then
    flag=2
    endif
    
    screener [flag=1](flag as “flag”)
    
    

    Hi,

    How can I add these conditions to the attached screener:

    1. Trading under 20 day simple moving average

    2. Price rang between 1 and 20

    Regards,

    Segie

    #248456 quote
    robertogozzi
    Moderator
    Master

    Try this one, not tested as at least one variable is missing:

    // — settings
    short = 12
    long = 26
    signal = 9
    // — end of settings
    EMAshort1 = exponentialaverage[short](close)
    EMAshort2 = exponentialaverage[short](EMAshort1)
    DifferenceShort = EMAshort1 - EMAshort2
    ZeroLagShort = EMAshort1 + DifferenceShort
    flag=0
    
    EMAlong1 = exponentialaverage[long](close)
    EMAlong2 = exponentialaverage[long](EMAlong1)
    DifferenceLong = EMAlong1 - EMAlong2
    ZeroLagLong = EMAlong1 + DifferenceLong
    
    ZeroLagMACD = ZeroLagShort - ZeroLagLong
    
    signal1=ExponentialAverage[signal](ZEROLAGMACD)
    signal2=ExponentialAverage[signal](signal1)
    DIFFERENCE2=signal1-signal2
    L1 = zerolagMACD crosses over  signalMACD
    L2 = close > average[20,0](close)
    S1 = zerolagMACD crosses under signalMACD
    S2 = close < average[20,0](close)
    C1 = (close >= 1) AND (close <= 20)
    if L1 AND L2 AND C1 then
    flag=1
    endif
    if S1 AND S2 AND C1 then
    flag=2
    endif
    
    screener [flag=1](flag as "flag")

    if you also want to get short signals, simply remove “=1” from the last line.

    segie thanked this post
    #248457 quote
    Iván González
    Moderator
    Master

    here you have the code:

    // — settings
    short = 12
    long = 26
    signal = 9
    // — end of settings
    EMAshort1 = exponentialaverage[short](close)
    EMAshort2 = exponentialaverage[short](EMAshort1)
    DifferenceShort = EMAshort1 - EMAshort2
    ZeroLagShort = EMAshort1 + DifferenceShort
    flag=0
    
    EMAlong1 = exponentialaverage[long](close)
    EMAlong2 = exponentialaverage[long](EMAlong1)
    DifferenceLong = EMAlong1 - EMAlong2
    ZeroLagLong = EMAlong1 + DifferenceLong
    
    ZeroLagMACD = ZeroLagShort - ZeroLagLong
    
    signal1=ExponentialAverage[signal](ZEROLAGMACD)
    signal2=ExponentialAverage[signal](signal1)
    DIFFERENCE2=signal1-signal2
    SignalMACD=signal1+DIFFERENCE2
    
    if zerolagMACD crosses over signalMACD then
    flag=1
    endif
    if zerolagMACD crosses under signalMACD then
    flag=2
    endif
    
    // Trading under SMA20
    sma20 = average[20](close)
    TradingUnderSma = close<sma20
    // Price between 1-20
    PriceRang = close>=1 and close<=20
    
    screener [flag=1 and TradingUnderSma and PriceRang](flag as "flag")
    
    robertogozzi and segie thanked this post
    #248482 quote
    segie
    Participant
    Senior

    Perfect. Thank you

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

PRC MACD screener with conditions


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
segie @segie Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by segie
8 months, 1 week ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 06/20/2025
Status: Active
Attachments: No files
Logo Logo
Loading...