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
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.
|
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
|