Moving Average cross over in the last X number of bars

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #17162 quote
    ck1066ck1066
    Participant
    Average

    Hi,

    How do I code the following condition?

    Long

    20 Exponential Moving average crosses over the 50 Exponential moving average in the last 20 bars

    #17176 quote
    GraHalGraHal
    Participant
    Master

    Assuming you want a Screener, try this?

    Filter = SUMMATION[20] (ExponentialAverage[20](close) crosses over ExponentialAverage[50](close))
    
    Screener (Filter)
    #17195 quote
    ck1066ck1066
    Participant
    Average

    Thanks I’ll give it a try.

    #17198 quote
    GraHalGraHal
    Participant
    Master

    I just noticed you said ‘Long’ so you probably need this?

     

    If SUMMATION[20] (ExponentialAverage[20](close) crosses over ExponentialAverage[50](close)) Then
    
    Buy 1 Contract at Market
    
    Endif
    #17819 quote
    ck1066ck1066
    Participant
    Average

    … and how would I also test if price crossed over the 50EMA in the previous X bars?

    I tried the below but didn’t work:

    SUMMATION[X](close) crosses over ExponentialAverage[50](close)) Then
    #17821 quote
    NicolasNicolas
    Keymaster
    Legend

    GraHal were almost correct, the summation should be tested if it is at least equal to 1:

    If SUMMATION[20] (ExponentialAverage[20](close) crosses over ExponentialAverage[50](close))>=1 Then
    
     Buy 1 Contract at Market
    
    Endif

    Here, the moving average cross over may have occured more than once, you can also modified the condition with “=1” instead of “>=1”.

Viewing 6 posts - 1 through 6 (of 6 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

Moving Average cross over in the last X number of bars


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
ck1066 @ck1066 Participant
Summary

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

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