Coding for recent EMA crossover

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #10745 quote
    Sam MacySam Macy
    Participant
    Junior

    Hi.

    If I have the following code, how could I include in the condition that the EMA crossover happens within the previous 3 days if it’s part of a larger scan with more conditions? As it stands this code could give results that have just crossed over or those that crossed over 6 month previous and are still climbing.

    In essence, sine EMA’s are lagging indicators I’d like to screen for crossovers that happened, say, within the last week or so.

    timeframe(Daily)
    
    EMA20 = ExponentialAverage[20] (close)
    EMA100 = ExponentialAverage[100] (close)
    
    Condition = (EMA20 > EMA100)
    
    SCREENER[Condition] 
    #11210 quote
    DerekDerek
    Participant
    Veteran

    Maybe an event variable will help:

    If ema1 crosses over ema2 then Event = 1 Else event = 0 Endif

     

    You can then screen for event [1]=1

    #11212 quote
    DerekDerek
    Participant
    Veteran

    The line breaks have got lost somehow in the code.

    If ema1 crosses over ema2 then
    Event = 1 
    Else 
    event = 0 
    Endif
    Nicolas, Sam Macy and Captain_Walker thanked this post
    #11222 quote
    Sam MacySam Macy
    Participant
    Junior

    Thanks Derek. I’ll give it a try…

    #11234 quote
    NicolasNicolas
    Keymaster
    Legend

    So what you want to do is to test if a crossover has happened in the past without having see it in real time? Am I right?

    Sam Macy thanked this post
    #11413 quote
    Sam MacySam Macy
    Participant
    Junior

    Yes – to see which stocks made the move in the last 5 days for instance…

    #11463 quote
    DerekDerek
    Participant
    Veteran

    I have coded something similar here, I think:

    screen condition c within last x days

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Coding for recent EMA crossover


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
Sam Macy @iainhmclean Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by DerekDerek
10 years, 1 month ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 07/21/2016
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...