A question about using the summation()

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #255255 quote
    thomas2004chthomas2004ch
    Participant
    Senior

    In the attached screenshot one can see the EMA5 crosses over the EMA10, EMA20 and the EMA50 within the last 5 days. So I wrote the code as follow:

    //P1=5
    MyEMA1 = ExponentialAverage[5](close)
    MyEMA2 = ExponentialAverage[10](close)
    MyEMA3 = ExponentialAverage[20](close)
    MyEMA4 = ExponentialAverage[50](close)
    
    Cross1 = MyEMA1 crosses over MyEMA2
    Cross2 = MyEMA1 crosses over MyEMA3
    Cross3 = MyEMA1 crosses over MyEMA4
    
    cP11 = summation[P1](Cross1) > 0
    cP12 = summation[P1](Cross2) > 0
    cP13 = summation[P1](Cross3) > 0
    cSummation1 = cP11 and cP12 and cP13
    
    
    return cSummation1

    But the RETURN is 0.

    As I just return the cP11 or cP12 or cP13, it is 1.

    Where is my problem?

    eamscrossover.png eamscrossover.png
    #255257 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    The screener is:

    P1=5
    MyEMA1 = ExponentialAverage[5](close)
    MyEMA2 = ExponentialAverage[10](close)
    MyEMA3 = ExponentialAverage[20](close)
    MyEMA4 = ExponentialAverage[50](close)
     
    Cross1 = MyEMA1 crosses over MyEMA2
    Cross2 = MyEMA1 crosses over MyEMA3
    Cross3 = MyEMA1 crosses over MyEMA4
     
    cP11 = summation[P1](Cross1) > 0
    cP12 = summation[P1](Cross2) > 0
    cP13 = summation[P1](Cross3) > 0
    cSummation1 = cP11 and cP12 and cP13
    
    SCREENER[cSummation1]

    in any case both the indicator and the screener are working as expected.

    #255258 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Hi! I can’t see it in the attached image.
    Your code is correct. The most likely problem is that all three crossovers are not occurring within the same 5-candle window at the same time.
    I have used this code below to visually see the junctions and I have checked on some assets and it works.
    If you give me details of the ticker, timeframe and date I can check it.

    P1=5
    MyEMA1 = ExponentialAverage[5](close)
    MyEMA2 = ExponentialAverage[10](close)
    MyEMA3 = ExponentialAverage[20](close)
    MyEMA4 = ExponentialAverage[50](close)
    
    Cross1 = MyEMA1 crosses over MyEMA2
    Cross2 = MyEMA1 crosses over MyEMA3
    Cross3 = MyEMA1 crosses over MyEMA4
    
    cP11 = summation[P1](Cross1) > 0
    cP12 = summation[P1](Cross2) > 0
    cP13 = summation[P1](Cross3) > 0
    
    cSummation1 = cP11 and cP12 and cP13
    
    if cSummation1 then
       backgroundcolor("green",30)
    endif
    
    return cP11, cP12*2, cP13*3, cSummation1*4 style(line,2)
    robertogozzi thanked this post
    #255259 quote
    thomas2004chthomas2004ch
    Participant
    Senior

    Sorry, maybe I made some error anywhere in my code. I rewrote my code and it works now.

    @Iván:

    The ticker is the Alamos Gold (AGI). You can test it during the August 2025.

    Iván González thanked this post
Viewing 4 posts - 1 through 4 (of 4 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

A question about using the summation()


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by thomas2004chthomas2004ch
8 months, 1 week ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 01/13/2026
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...