Lookback Period/Sorting

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #147807 quote
    Guacamole2020Guacamole2020
    Participant
    New

    Is it possible to add a look-back period to scanner?

    p1=9
    p2=26
    
    
    REM Tenkan-Sen = (Highest High + Lowest Low) / 2, for the past 9 days
    Upper1 = HIGHEST[p1](HIGH)
    Lower1 = LOWEST[p1](LOW)
    Tenkan = (Upper1 + Lower1) / 2
    
    REM Kijun-Sen = (Highest High + Lowest Low) / 2, for the past 26 days
    Upper2 = HIGHEST[p2](HIGH)
    Lower2 = LOWEST[p2](LOW)
    Kijun = (Upper2 + Lower2) / 2
    
    
    TENLESSKIJUN = (Tenkan < Kijun)
    //TENGREATKIJUNPAST = Tenkan[7] > Kijun[7]
    CLOSEVAL = (close < 1100 AND close > 50)
    VOL = (volume > 1000000)
    
    
    //Screener((TENLESSKIJUN AND TENGREATKIJUNPAST AND CLOSEVAL AND VOL))
    Screener[TENLESSKIJUN AND CLOSEVAL AND VOL ]
    

    Above is a very simple TK cross over detection screener, however , this will output anything where a TK cross has taken place (and valid). Is it possible to bracket this by only running the script for a time period i.e last 7 days?

    Secondly is it possible to have the results of screener sorted by the time? By time , i mean , not the scan time , but rather , if asset_1 had a TK-cross on 1st October and asset_2 on 2nd October , is there a way i can list asset_2 before asset_1 in sorting criteria?

     

    Thanks!

    #147813 quote
    NicolasNicolas
    Keymaster
    Legend

    In this version of the code, i’m checking if a crosses have occurred in the last 7 periods:

    p1=9
    p2=26
    
    
    REM Tenkan-Sen = (Highest High + Lowest Low) / 2, for the past 9 days
    Upper1 = HIGHEST[p1](HIGH)
    Lower1 = LOWEST[p1](LOW)
    Tenkan = (Upper1 + Lower1) / 2
    
    REM Kijun-Sen = (Highest High + Lowest Low) / 2, for the past 26 days
    Upper2 = HIGHEST[p2](HIGH)
    Lower2 = LOWEST[p2](LOW)
    Kijun = (Upper2 + Lower2) / 2
    
    
    TENLESSKIJUN = (Tenkan crosses under Kijun)
    
    if TENLESSKIJUN then 
     lastcross = barindex //save the barindex of the event 
    endif
    
    CLOSEVAL = (close < 1100 AND close > 50)
    VOL = (volume > 1000000)
    last = barindex-lastcross <=7 //last cross was less than 7 periods from now
    
    Screener[last AND CLOSEVAL AND VOL](barindex-lastcross as "x bars ago")

    I also added the bars difference for the sorting criteria, as you required. This code has not been tested.

    Guacamole2020 thanked this post
    #147882 quote
    Guacamole2020Guacamole2020
    Participant
    New

    thanks! i’ll give it a spin!

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

Lookback Period/Sorting


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Guacamole2020Guacamole2020
5 years, 11 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 10/19/2020
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...