Stochastic & Ema Crossover Screener

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

    Hi Everyone,

    I am new to coding and prorealtime too. I would like to code a screener that has more conditions, hope to get some help here.

    Is it necessay to state the screener timeframe? i am looking to do daily screening.

    Condition for buy :

    1. 20 EMA is higher than the 50 EMA.
    2. And, the stochastic K line CROSS OVER the D line
    3. And closing price is higher than the 50 EMA.

    Note: i would like to use stochastic ( 14, 5, 3)

    Thank you

    #69266 quote
    robertogozzi
    Moderator
    Master

    I created a new topic, since you are requesting something different, though slightly, from a Stochastic Crossover.

    I already have some code, I just need to change it a bit. I’ll try to post something as soon as possible.

    Roberto

    #69268 quote
    robertogozzi
    Moderator
    Master

    There you go (for Short trades you’ll have to test conditions the other way round). You do not need to state the timeframe in the code itself, as far as you check only one, just select the one you want in the screener box when you create it.

    StocK = Stochastic[14,5](close)
    StocD = Average[3,0](StocK)
    Ema50 = Average[50,1](close)
    Ema20 = Average[20,1](close)
    Up    = Ema20 > Ema50 AND close > Ema50 AND StocK CROSSES OVER StocD
    IF Up THEN
       Result = 1
    ELSE
       Result = 0
    ENDIF
    SCREENER[Result] (Result AS "Up")

    To know what the second parameter in AVERAGE means you may read https://www.prorealcode.com/documentation/average/.

    Roberto

    #69281 quote
    General500
    Participant
    New

    thanks Roberto, will try it out!

    #75943 quote
    MrMagic
    Participant
    Average

    Hi,

    I tried some modifications to short trades but came up with nothing across the timeframes. Can you please check this to see where my error is?

    StocK = Stochastic[14,3](close)
    StocD = Average[3](StocK)
    Ema100 = Average[100,1](close)
    Ema50 = Average[50,1](close)
    Ema20 = Average[20,1](close)
    Down = Ema20 < Ema50 and Ema50 < Ema100 AND close < Ema50 AND StocK CROSSES UNDER StocD
    IF Down THEN
    Result = 1
    ELSE
    Result = 0
    ENDIF
    SCREENER[Result] (Result AS "Down")
    
    #75944 quote
    MrMagic
    Participant
    Average

    Hi,

    Also tried this combination to see if it makes any difference. I’m still very new and poor at coding.

    StocK = Stochastic[14,3](close)
    StocD = Average[3](StocK)
    Ema100 = Average[100,1](close)
    Ema50 = Average[50,1](close)
    Ema20 = Average[20,1](close)
    Up = Ema20 > Ema50 and Ema50 > Ema100 AND close > Ema50 AND StocK CROSSES OVER StocD
    Dn = Ema20 < Ema50 and Ema50 < Ema100 AND close < Ema50 AND StocK CROSSES UNDER StocD
    ReturnValue = 0
    IF Dn THEN
    ReturnValue = -1
    ELSIF Up THEN
    ReturnValue = 1
    ENDIF
     
    SCREENER[ReturnValue] (ReturnValue AS "1=Up / -1=Dn")
    #75963 quote
    robertogozzi
    Moderator
    Master

    When you make corrections/integrations, only add ONE at a time, because the more you add to the original code the more difficult it will be to detect errors.

    So, first let’s add the SHORT scan:

    StocK = Stochastic[14,5](close)
    StocD = Average[3,0](StocK)
    Ema50 = Average[50,1](close)
    Ema20 = Average[20,1](close)
    Up    = Ema20 > Ema50 AND close > Ema50 AND StocK CROSSES OVER  StocD
    Dn    = Ema20 < Ema50 AND close < Ema50 AND StocK CROSSES UNDER StocD
    Result = 0
    IF Up THEN
       Result = 1
    ELSIF Dn THEN
       Result = 2
    ENDIF
    SCREENER[Result] (Result AS "1=Up/2=Dn")

    When it works as expected you may add new features (one at a time!), like a new MA as you did.

    MrMagic thanked this post
    x-5.jpg x-5.jpg
    #75985 quote
    MrMagic
    Participant
    Average

    Dear robertogozzi,

    Thanks for going through the trouble to produce the codes. I’d like a final request to combine these codes if you don’t mind.

    LONG

    H4 stochastic and H1 stochastic (14,3,5) %K > %D in both with price above EMA 50 in both and EMA 20 above EMA 50 and EMA 50 above EMA 100

    SHORT

    H4 stochastic and H1 stochastic (14,3,5) %K < %D in both with price below EMA 50 in both and EMA 20 below EMA 50, and EMA 50 below EMA 100

    I hope with this I’ll be able to stop bothering you.

    #75987 quote
    robertogozzi
    Moderator
    Master

    There you go

    TIMEFRAME(4 hours)
    StocKa  = Stochastic[14,5](close)
    StocDa  = Average[3,0](StocKa)
    Ema100a = Average[100,1](close)
    Ema50a  = Average[50,1](close)
    Ema20a  = Average[20,1](close)
    UPa     = close > Ema50a AND Ema20a > Ema50a AND Ema50a > Ema100a AND StocKa > StocDa
    DNa     = close < Ema50a AND Ema20a < Ema50a AND Ema50a < Ema100a AND StocKa < StocDa
    
    TIMEFRAME(1 hour)
    StocKb  = Stochastic[14,5](close)
    StocDb  = Average[3,0](StocKb)
    Ema100b = Average[100,1](close)
    Ema50b  = Average[50,1](close)
    Ema20b  = Average[20,1](close)
    UPb     = close > Ema50b AND Ema20b > Ema50b AND Ema50b > Ema100b AND StocKb > StocDb
    DNb     = close < Ema50b AND Ema20b < Ema50b AND Ema50b < Ema100b AND StocKb < StocDb
    
    TIMEFRAME(default)
    Result = 0
    IF UPa AND UPb THEN
       Result = 1
    ELSIF DNa AND DNb THEN
       Result = 2
    ENDIF
    SCREENER[Result] (Result AS "1=Up/2=Dn")

    LONG

    H4 stochastic and H1 stochastic (14,3,5) %K > %D in both with price above EMA 50 in both and EMA 20 above EMA 50 and EMA 50 above EMA 100

    SHORT

    H4 stochastic and H1 stochastic (14,3,5) %K < %D in both with price below EMA 50 in both and EMA 20 below EMA 50, and EMA 50 below EMA 100

    You didn’t write BOTH after the hilighted words, as you had done before. I assumed it in the above code. Should you have meant NOT TO PURPOSELY write that word, then the code changes a bit as follows:

    TIMEFRAME(4 hours)
    StocKa  = Stochastic[14,5](close)
    StocDa  = Average[3,0](StocKa)
    Ema50a  = Average[50,1](close)
    UPa     = close > Ema50a AND StocKa > StocDa
    DNa     = close < Ema50a AND StocKa < StocDa
    
    TIMEFRAME(1 hour)
    StocKb  = Stochastic[14,5](close)
    StocDb  = Average[3,0](StocKb)
    Ema50b  = Average[50,1](close)
    UPb     = close > Ema50b AND StocKb > StocDb
    DNb     = close < Ema50b AND StocKb < StocDb
    
    TIMEFRAME(default)
    Ema100  = Average[100,1](close)
    Ema50   = Average[50,1](close)
    Ema20   = Average[20,1](close)
    UP      = Ema20 > Ema50 AND Ema50 > Ema100
    DN      = Ema20 < Ema50 AND Ema50 < Ema100
    
    Result = 0
    IF UPa AND UPb AND UP THEN
       Result = 1
    ELSIF DNa AND DNb AND DN THEN
       Result = 2
    ENDIF
    SCREENER[Result] (Result AS "1=Up/2=Dn")
    MrMagic thanked this post
    #76018 quote
    MrMagic
    Participant
    Average

    Hi,

    Thanks for the reply. I put the word ‘BOTH’ to mean that the criteria should be met in both timeframes and thanks for specifying. Cheers.

    #76398 quote
    MrMagic
    Participant
    Average

    Hi,

    From the code you created below, how does one screen the 1 hour timeframe for stochastic crossover below 20 and crossunder above 80?

    TIMEFRAME(daily)
    StocKa  = Stochastic[14,3](close)
    StocDa  = Average[5,0](StocKa)
    UPa     = StocKa > StocDa
    DNa     = StocKa < StocDa
     
    TIMEFRAME(1 hour)
    StocKb  = Stochastic[14,3](close)
    StocDb  = Average[5,0](StocKb)
    Ema50b  = Average[50,1](close)
    UPb     = close > Ema50b AND StocKb > StocDb AND Stockb < 20
    DNb     = close < Ema50b AND StocKb < StocDb AND Stockb > 80
     
    TIMEFRAME(default)
    Result = 0
    IF UPa AND UPb THEN
    Result = 1
    ELSIF DNa AND DNb THEN
    Result = 2
    ENDIF
    SCREENER[Result] (Result AS "1=Up/2=Dn")
    #76408 quote
    robertogozzi
    Moderator
    Master

    Like I did  at post https://www.prorealcode.com/topic/split-stochastic-ema-crossover-screener/#post-75944, lines 6 and 7. Instead of testing whether something is > or < or = than something else you just need to write CROSSES OVER or CROSSES UNDER.

    Lines 11 and 12 of your code above should be replaced by

    //UPb   = close > Ema50b AND StocKb > StocDb AND Stockb < 20
    //DNb   = close < Ema50b AND StocKb < StocDb AND Stockb > 80
    UPb     = close > Ema50b AND StocKb > StocDb AND Stockb CROSSES UNDER 20
    DNb     = close < Ema50b AND StocKb < StocDb AND Stockb CROSSES OVER  80
    MrMagic thanked this post
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

Stochastic & Ema Crossover Screener


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
General500 @general500 Participant
Summary

This topic contains 11 replies,
has 3 voices, and was last updated by robertogozzi
7 years, 8 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 04/27/2018
Status: Active
Attachments: 1 files
Logo Logo
Loading...