Moving Average cross over in the last X number of bars

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #17162 quote
    ck1066
    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
    GraHal
    Participant
    Master

    Assuming you want a Screener, try this?

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

    Thanks I’ll give it a try.

    #17198 quote
    GraHal
    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
    ck1066
    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
    Nicolas
    Keymaster
    Master

    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.

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 Nicolas
9 years, 2 months ago.

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