Non-crossover of moving averages

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #115624 quote
    rochnickols
    Participant
    New

    Dear forum members,

    This is my first post on this forum.
    I am looking for help in programming proscreeners and in first place a non-crossover indicator between two moving averages.
    Let us cut it down into subcomponents and to start with in case of a bullish non-crossover the screener requires for a moving average – let’s take a standard 7-period moving average – to have a negative orientation in three successive period and to reverse higher during a fourth period.

    If forum members can help with this first piece we will then move to the next part of the screener.

    Thanks for help.

    #115629 quote
    robertogozzi
    Moderator
    Master

    There you go (not tested):

    MyAvg = average[7](close)
    Result = MyAvg > MyAvg[1] and (summation[3](MyAvg < MyAvg[1])[1] = 3)
    Screener[Result]
    rochnickols thanked this post
    #115640 quote
    rochnickols
    Participant
    New

    Thank you Roberto, seems the code is working.

    Could we now please add the following criteria:
    a) Standard 20-period moving average is positive (last value > previous value), and
    b) Last stock price close is above last M7 value

    Thank you.

    #115644 quote
    robertogozzi
    Moderator
    Master

    There you go:

    Sma20  = average[20,0](close)
    MyAvg  = average[7,0](close)
    Result = MyAvg > MyAvg[1] and (summation[3](MyAvg < MyAvg[1])[1] = 3)
    Result = Result AND Sma20 > Sma20[1] AND close > MyAvg
    Screener[Result]

    adding ,0 to averages is useless, I added it just to show that there’s an optional parameter to calculate different types, see https://www.prorealcode.com/documentation/average/.

    rochnickols thanked this post
    #115676 quote
    rochnickols
    Participant
    New

    Great. Thank you so much. Works perfectly.
    Have added lines of code to select minimum capital exchanged I had obtained long time ago.
    Although it works I am wondering if it can be streamlined.

    Happy 2020.

    // Non-crossover M7/M20
    Sma20 = average[20,0](close)
    MyAvg = average[7,0](close)
    KapitalMini = 2000 // Minimum Capital (in K)
    Kapital = Volume * WeightedClose / 1000
    KapitalOK = ( Kapital > KapitalMini )
    
    Result = MyAvg > MyAvg[1] and (summation[3](MyAvg < MyAvg[1])[1] = 3)
    Result = Result AND Sma20 > Sma20[1] AND close > MyAvg AND KapitalOK
    Screener[Result]
    #115679 quote
    robertogozzi
    Moderator
    Master

    Some suggestions:

    • For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text from the code part!
    • Do NOT quote all posts, as it makes reading topics slower and more dificult. Do it when many people update that topic and you need to refer to someone specifically. This topic is just us two! Thank you  🙂

    As to streamlining it can always be done, depending on what are your goals. Post your details and myself or someone else may help you further.

    #115948 quote
    Nicolas
    Keymaster
    Master

    Another topic for non-crossover of moving average: https://www.prorealcode.com/topic/codage-non-croisement-d-mm/

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

Non-crossover of moving averages


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

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

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 12/30/2019
Status: Active
Attachments: No files
Logo Logo
Loading...