StockFetcher Forums · General Discussion · count days and output "true" in columns?<< >>Post Follow-up
fotchstecker
304 posts
msg #149963
Ignore fotchstecker
12/21/2019 6:47:24 PM

I'm not quite sure of how to do the following 2 things:

1. In a column, I want to output a the number of times a condition was true over a number of days.
E.g. Count of gaps-up over the last [12] days.

1. I want to count the number of "days since" a particular condition was last true in a column.
E.g.: Count of days since stock last gapped up (count of days since last true).

Any ideas on how to do these? Much appreciate any thoughts. Thank you.

xarlor
587 posts
msg #149967
Ignore xarlor
modified
12/21/2019 10:15:25 PM

Fetcher[
/* Number of times stock gapped up more than 5% within the last 12 days */

market not otcbb
average volume(30) > 1234567
set{GapUps,count(close-to-open gap > 5,12)}
add column GapUps
sort column 5 descending
]



Fetcher[
/* Days since stock gapped up more than 20%. Limit search to last 60 days */

market not otcbb
close > 1
average volume(30) > 1234567
set{LastGap,days(close-to-open gap > 20,60)}
LastGap > -1
add column LastGap
sort column 5 ascending
]



Edit: Removed extraneous line "Close-to-open gap"

fotchstecker
304 posts
msg #149973
Ignore fotchstecker
12/22/2019 2:13:31 PM

Thank you, Xarlor. I appreciate it very much.

Is the following valid for substituting an average for the static percent value? I want to check how many days over the last X days the gaps were greater than the 100-day average absolute value of gaps. I get output for the below but I'm not certain it's correct for the evaluation I want.

set{SinceLastGap,days(close-to-open gap > cma(absgap, 100),60)}
SinceLastGap > -1
add column SinceLastGap

xarlor
587 posts
msg #149974
Ignore xarlor
12/22/2019 2:33:27 PM

Is this part of a larger filter where you defined the variable absgap? This snippet of code doesn't return anything so I suspect it's part of a larger filter.

fotchstecker
304 posts
msg #150028
Ignore fotchstecker
modified
12/27/2019 4:19:33 PM

Hi, xarlor -- happy almost new year. yes, absgap is part of a set statement.

Do you know how to calculate separate averages for gaps up and gaps down? I can use abs to calculate "any gap", but I need to know the idividual average gap size for gaps-down and then for gaps-up.

This is where a gap would be the change between the open and the close of the previous day (1 day ago).


--average gap UP over last 10 days

--average gap DOWN over last 10 days

...both in dollars.

xarlor
587 posts
msg #150031
Ignore xarlor
12/27/2019 11:08:29 PM

I'm not sure how to isolate gap days to then calculate the average. However, if you got that part already figured out and all you need to do is separate gap ups with gap downs, then using the close-to-open gap works both ways.

Fetcher[
market not otcbb
average volume(30) > 1234567
set{GapUps,count(close-to-open gap > 5,12)}
set{GapDowns,count(close-to-open gap < -5,12)}
add column GapUps
add column GapDowns
]



fotchstecker
304 posts
msg #150040
Ignore fotchstecker
modified
12/28/2019 3:22:50 PM

not right yet. this is just averaging the counts.

set{Xgapped, open - close 1 day ago}
set{Xgapup, count(Xgapped > 0, 1)}
set{avg_chg_up,sum(Xgapup,100) / 100}
add column avg_chg_up

set{Xgapped1, open - close 1 day ago}
set{Xgapdn, count(Xgapped1 < 0, 1)}
set{avg_chg_dn,sum(Xgapdn,100) / 100}
add column avg_chg_dn



market is etf

StockFetcher Forums · General Discussion · count days and output "true" in columns?<< >>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.