Lookback Period/Sorting
Forums › ProRealTime English forum › ProScreener support › Lookback Period/Sorting
- This topic has 2 replies, 2 voices, and was last updated 4 years ago by
Guacamole2020.
-
-
10/19/2020 at 10:38 PM #147807
Is it possible to add a look-back period to scanner?
1234567891011121314151617181920212223p1=9p2=26REM Tenkan-Sen = (Highest High + Lowest Low) / 2, for the past 9 daysUpper1 = HIGHEST[p1](HIGH)Lower1 = LOWEST[p1](LOW)Tenkan = (Upper1 + Lower1) / 2REM Kijun-Sen = (Highest High + Lowest Low) / 2, for the past 26 daysUpper2 = HIGHEST[p2](HIGH)Lower2 = LOWEST[p2](LOW)Kijun = (Upper2 + Lower2) / 2TENLESSKIJUN = (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!
10/20/2020 at 7:44 AM #147813In this version of the code, i’m checking if a crosses have occurred in the last 7 periods:
1234567891011121314151617181920212223242526p1=9p2=26REM Tenkan-Sen = (Highest High + Lowest Low) / 2, for the past 9 daysUpper1 = HIGHEST[p1](HIGH)Lower1 = LOWEST[p1](LOW)Tenkan = (Upper1 + Lower1) / 2REM Kijun-Sen = (Highest High + Lowest Low) / 2, for the past 26 daysUpper2 = HIGHEST[p2](HIGH)Lower2 = LOWEST[p2](LOW)Kijun = (Upper2 + Lower2) / 2TENLESSKIJUN = (Tenkan crosses under Kijun)if TENLESSKIJUN thenlastcross = barindex //save the barindex of the eventendifCLOSEVAL = (close < 1100 AND close > 50)VOL = (volume > 1000000)last = barindex-lastcross <=7 //last cross was less than 7 periods from nowScreener[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.
1 user thanked author for this post.
10/20/2020 at 11:06 AM #147882thanks! i’ll give it a spin!
-
AuthorPosts