Counting candles for the periods a condition is met

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #81481 quote
    HallgenteHallgente
    Participant
    New

    Hi – Here’s a simple bit of moving average code. Rather than have the last column as RSI, is it possible to have a column that shows a count for how many periods the screener condition has been met?

    MyMa1=average[8](Close)
    MyMa2 = average[13](Close)
    MyRSI=RSI[14](Close)
    CloseA=Close
    CloseB=Close[1]
    REM Close1=Close[1]
    c1=CloseA>MyMa1
    c2=CloseA>MyMa2
    c3=CloseB>MyMA1
    REM c2=Close1>MyMa1
    
    SCREENER [c1 AND c2 AND c3] (MyRSI AS "RSI")
    
    
    #81482 quote
    VonasiVonasi
    Moderator
    Master

    Please use the ‘Insert PRT Code’ button when putting code in your posts as it makes it much easier for others to read. I have tidied up your post for you. 🙂

    #81512 quote
    NicolasNicolas
    Keymaster
    Legend

    This version of the screener, it should make a count of how many times the “test” condition was true and display it in the criteria column:

    MyMa1=average[8](Close)
    MyMa2 = average[13](Close)
    //MyRSI=RSI[14](Close)
    CloseA=Close
    CloseB=Close[1]
    REM Close1=Close[1]
    c1=CloseA>MyMa1
    c2=CloseA>MyMa2
    c3=CloseB>MyMA1
    REM c2=Close1>MyMa1
    
    test = c1 AND c2 AND c3
    
    if test and test[1] then 
    count=count+1
    else
    count=0
    endif
    
    SCREENER [test] (count)
    #81559 quote
    HallgenteHallgente
    Participant
    New

    Thank you!

    #81560 quote
    HallgenteHallgente
    Participant
    New

    You’re now on my Christmas card list…..

    #81653 quote
    NicolasNicolas
    Keymaster
    Legend

    Glad to know it! Got plenty of things in my Amazon wish list 😆

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

Counting candles for the periods a condition is met


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
Hallgente @hallgente Participant
Summary

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

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 09/27/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...