Coding a rise in the Moving Average

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #16601 quote
    David R Pierce
    Participant
    New

    Hi all,

    I’ve scoured the forum to try and find the answer to this, tried a few methods, but couldn’t get a narrower search on ProScreener.

    Basically I want to display markets where the 200 day Simple Moving Average is higher than it was 21 bars ago (as an example)

    I’ve tried this:

    indicator3 = Average[200](close)
    c1 = (indicator3 > indicator3[21])

    I found that this either displayed Simple Moving Averages that were also DEclining or it increased the number of results it displayed!

    Any help would be much appreciated – I’m still a bit new to the coding world.

    Many thanks, David.

    #16629 quote
    GraHal
    Participant
    Master

    Good Morning David

    If you put your full Screener code up on here then I / others could try it on our Platforms and see what we get as a result.

    I’m sure you included ‘SCREENER’ at the end of your code? Somebody would spot the error (even I might! ha) in an instant if they see the full code.

    Cheers

    GraHal

    #16682 quote
    David R Pierce
    Participant
    New

    Hi GraHal,

    Thanks for your reply!  Here’s the full code:

    indicator1 = ExponentialAverage[5](close)
    indicator2 = ExponentialAverage[21](close)
    c1 = summation[2](indicator1 CROSSES OVER indicator2)
    
    indicator3 = Average[200](close)
    c1 = (indicator3 > indicator3[21])
    
    SCREENER[c1] ((close/DClose(1)-1)*100 AS "%Chg yest.")

    I’m sure it’s something simple i’m missing.  But again, any help would be much appreciated.

    Thanks, David.

    #16708 quote
    GraHal
    Participant
    Master

    Hi David

    Try below. You had 2 x C1.

    Summation[2] gives indicator1 CROSSES OVER indicator2 2 days ago? Without summation[2] the Screener gives the cross yesterday … is that what you want?

    indicator1 = ExponentialAverage[5](close)
    indicator2 = ExponentialAverage[21](close)
    c1 = (indicator1 CROSSES OVER indicator2)
    indicator3 = Average[200](close)
    c2 = (indicator3 > indicator3[21])
    SCREENER[c1 and C2] ((close/DClose(1)-1)*100 AS "%Chg yest.")

    Cheers

    GraHal

    Nicolas thanked this post
    #16719 quote
    GraHal
    Participant
    Master

    Mmm I edited my original message above and it has screwed the PRT Code, sorry about that.  Ohh its back okay again now …  Nicolas must have fixed it? Thank you Nicolas!

    You were probably just ‘too close to it’ to spot the 2 instances of C1?

    Happy to Help

    GraHal

    #16749 quote
    David R Pierce
    Participant
    New

    It works great now – many thanks.

    It was a case of noticing there are 2 ‘C1’s’ – Lesson learned for me.

    Thanks again.

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

Coding a rise in the Moving Average


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by David R Pierce
9 years, 3 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 11/16/2016
Status: Active
Attachments: No files
Logo Logo
Loading...