StockFetcher Forums · General Discussion · get reference to the last occurrence of condition<< >>Post Follow-up
Venice
82 posts
msg #146972
Ignore Venice
modified
3/17/2019 7:21:59 PM

Hi,

I hope i can explain what i mean by the title. I am trying to find the last occurrence of, say, a bull bar, then i need to get the high from that bull bar.

I can specify days ago, but that's not quite right, because I want to pragmatically figure out when it happened.

Something akin to this (i know this doesn't work in SF, but hopefully more programming related example will help:

set{bullBarDay, getBarDayWhen(close > open)}
set{bullBarHigh, high $bullBarDay days ago}

Thanks!


four
5,087 posts
msg #146977
Ignore four
modified
3/17/2019 11:25:14 PM

perhaps...

https://www.stockfetcher.com/forums/Indicators/Date-Based-References-DATE/126346

/* Reference a specific date */
DATE(20190211,close) > DATE(20190211,open)
set{var1,DATE(20190211,high)}
draw var1 on plot price
add column var1



Venice
82 posts
msg #146987
Ignore Venice
3/18/2019 12:12:36 PM

Hey Four,

Thanks for taking a look. This still assumes I know when the bull bar is though; It's super painful trying to save price information and reference it later, if not impossible (that I know of).

Guess for this particular strategy, i'll just visually scan a set of personally picked stocks.

four
5,087 posts
msg #146988
Ignore four
modified
3/18/2019 12:21:47 PM

It allows you to
0. create watchlist and
1. pick a date and
2. require close > open on that date and
3. draw a line on that date high then
3. visually scan
--------------
Thanks for letting me give it a try--I don't use DATE

nibor100
1,045 posts
msg #147001
Ignore nibor100
3/19/2019 11:35:12 AM

@venice,

I'm a little lost following what you want to do, as once you have caught up to date on your personalized list of stocks, you could easily run a filter each night that finds just today's bull bar stocks and identifies their Highs for use in the rest of your filter.

Thanks,
Ed S.



Venice
82 posts
msg #147039
Ignore Venice
modified
3/21/2019 6:47:15 PM

Yeah, sorry about that - i gave a rather simple example just to see if it could be achieved.

So maybe to expand a bit more, Lets say we have the following filter...

low 10 days ago reached a new 30 day low.

^ Given that that reaches a new low, we can assume price is heading down. Now, I need the high of the last bull bar 11+ days ago. It could have happened 11 days ago, or it could have happened 20 days ago. It's at an unknown position/index. I then want to filter for stocks who have achieved some criteria against this high (lets say, reached the high) within the last 10 days.

So high within the last 10 days > high of the last bull bar (found between +11 and n days ago), while the low reached a new 30 day low between 11+ days and the last bull bar.

I bet there is some sort of math that could figure it out. But not quite sure what it is.

nibor100
1,045 posts
msg #147055
Ignore nibor100
3/24/2019 12:30:06 PM

@venice,

Implementing your last post I think the filter below crudely gets you what you described you were looking for:

Fetcher[
low 10 days ago reached a new 30 day low
/*var13 > 0*/

set{var1,close - open}
set{var2,var1 11 days ago}
draw var2

set{var3,count (var2 > 0, 1)}
add column days(var2 > 0,20) {last Bull Bar Days before LOW} sort on column 5 descending

set{var13,count (days(var2 > 0,20)is equal to 13, 1)}
set{High23DaysAgo,var13 * high 23 days ago} add column High23DaysAgo
set{var12,count (days(var2 > 0,20)is equal to 12, 1)}
set{High22DaysAgo,var12 * high 22 days ago} add column High22DaysAgo
set{var11,count (days(var2 > 0,20)is equal to 11, 1)}
set{High21DaysAgo,var11 * high 21 days ago} add column High21DaysAgo
set{var10,count (days(var2 > 0,20)is equal to 10, 1)}
set{High20DaysAgo,var10 * high 20 days ago} add column High20DaysAgo
set{var9,count (days(var2 > 0,20)is equal to 9, 1)}
set{High19DaysAgo,var9 * high 19 days ago} add column High19DaysAgo
set{var8,count (days(var2 > 0,20)is equal to 8, 1)}
set{High18DaysAgo,var8 * high 18 days ago} add column High18DaysAgo
set{var7,count (days(var2 > 0,20)is equal to 7, 1)}
set{High17DaysAgo,var7 * high 17 days ago} add column High17DaysAgo
set{var6,count (days(var2 > 0,20)is equal to 6, 1)}
set{High16DaysAgo,var6 * high 16 days ago} add column High16DaysAgo
set{var5,count (days(var2 > 0,20)is equal to 5, 1)}
set{High15DaysAgo,var5 * high 15 days ago} add column High15DaysAgo
set{var4,count (days(var2 > 0,20)is equal to 4, 1)}
set{High14DaysAgo,var4 * high 14 days ago} add column High14DaysAgo
set{var33,count (days(var2 > 0,20)is equal to 3, 1)}
set{High13DaysAgo,var33 * high 13 days ago} add column High13DaysAgo
set{var22,count (days(var2 > 0,20)is equal to 2, 1)}
set{High12DaysAgo,var22 * high 12 days ago} add column High12DaysAgo
set{var111,count (days(var2 > 0,20)is equal to 1, 1)}
set{High11DaysAgo,var111 * high 11 days ago} add column High11DaysAgo

/*add column high 0 days ago*/
]



a. the results are sorted by the number of days prior to the "low 10 days ago reached a new 30 day low" on which the prior Bull Bar occurred.

Running the filter, as is, today indicates that 1,081 stocks had a low 10 days ago reach a new 30 day low and column 5 indicates the farthest in the past a bull bar last occurred was 13 days prior.

b. So you look to the right of the # in the sorted column to find the high for that many days back that the Bull Bar occurred on. Zeros mean the Bull Bar occurred on a different numbered day.

c. To minimize scrolling etc. you can remove the comment symbols /* */ and change the number in the "var#' in the filters first comment line to your desired day in the past and rerun the filter to get a shorter list.

Let me know if this isn't what you wanted or if there are any questions.
Ed S.

Venice
82 posts
msg #147075
Ignore Venice
3/25/2019 5:23:02 PM

Very cool; I think this is getting closer to what i want. Let me kick it around a little bit and see if i can get it tuned in to what i am trying to achieve!

Thanks a ton!


StockFetcher Forums · General Discussion · get reference to the last occurrence of condition<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.