Coding a Moving Average crossover

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

     Hi all,

    I usually have no problems with this type of code as you can basically select the criteria with ProScreener.

     However, this one is not bringing up anything at all! (even if I select it to look at all markets).  I’m basically looking to find markets where the 21 day EMA has crossed over the 400SMA within the last 100 days/periods on a daily chart.

     

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

     

    Any help would be great.  

    Also a random question – ProScreener shows the top 50 results.  Is there a way to view the next 50?

    Many thanks, David.

    #16802 quote
    GraHal
    Participant
    Master
    <p>Hi David</p><p>Have you tried changing Crosses Over  to > or < just to see if your Screener springs into life with some results?</p><p>Cheers</p><p>GraHal </p>
    #16806 quote
    GraHal
    Participant
    Master

    Mmm my message above screwed again … what am I doing wrong!

    I got your code working, but not above MA [250] … must be to do with the ‘preload bars’ … but I cant see a preload bars command to increaser to 400.

    There were 7 hits using Average[250](close)and Cross Over on a Daily TF.

     

    DP.jpg DP.jpg
    #16809 quote
    GraHal
    Participant
    Master

    Re  the next 50 results, I suggest you try putting a filter / limit on your sort criteria starting at result 50 so as to show result 51 to 100. Hope that makes sense? 

    #16817 quote
    David R Pierce
    Participant
    New

    Hi,

    Thanks for your help again.  Yes it’s strange that it will allow the code to work with a 250SMA but not a 400SMA!

    Using a 250SMA however would help me spot markets that are heading towards the 400SMA anyway so that may be more ideal. :o)

    Can I ask what you mean by preload bars?

    Thanks, David.

    #16827 quote
    Nicolas
    Keymaster
    Master
    You can’t get results which are oldest than 256 periods. So if you want to test a crossover of a SMA200 that occured 60 periods ago, it is not possible because a 200 periods SMA needs of course 200 periods to compute correctly and it’s getting worse with EMA for instance. This is a limitation of the Proscreener module ..
    #16844 quote
    GraHal
    Participant
    Master

    Preload bars are the numbers of bars that are pre loaded at the beginning of a backtest or for a screener.

    A 250 MA needs 250 bars in order to compute the Moving Average so as Nicolas says (this is his site btw :)) the limit is 256 bars … hence why the MA not give any hits above MA 256? (I didnt try 256, only 250).

    On Backtest you can select the Command ‘Preload Bars’ and enter what you wish (up to a limit). The default PreLoad on Backtest is 200 Bars.  

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

Coding a Moving Average crossover


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by GraHal
9 years, 3 months ago.

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