StockFetcher Forums · General Discussion · How to find the last time something happened<< >>Post Follow-up
JoeyVinyl
120 posts
msg #152258
Ignore JoeyVinyl
modified
5/20/2020 10:57:27 PM

I looked through the manual and tried searching the forums but I have no idea how to search for what I want to know. Hence, this post.

The question: Is it possible to find out how many days since something happened, like a stock closing 10% or more above its open?

Let's say I have a line of code that counts how many times a stock price rose up to close at least 10% above its open in the last 100 days. If you've seen any of the Crock Pot variations you'll know what I mean but for those who aren't familiar with that legend let me give you this (I know that most of the ones I've seen use "high - open" but I want to know where it closed rather than how high it went since I can't be watching for the high all the time):

set {dayup, close - open}
set {gain, dayup / open}
set {win, count(gain > .10, 100)}
add column win

Simple enough, right? In my own Crock Pot version I broke it down into five 20 day periods in order to see if it was happening more recently. To me, a stock that's closing 10% higher in the last month is more interesting than one that hasn't done it in six months or more. But even that didn't tell me exactly when it happened.

So I'm on a quest to see if there's some SF code that can tell me "it's been this many days since the last time this event happened." I hope there is.

ETA: I know I can use the "days ago" phrase to see if something happened x number of days in the past, but that would mean creating a lot of set statements, depending on how much I wanted to narrow down the time. I'm hoping there's an easier way to do it.

nibor100
610 posts
msg #152260
Ignore nibor100
5/21/2020 4:02:39 AM

You needed to search on "days since".
here is an example line

add column days(gain > .10,100)

that should, find and/or not find, the number of days, in the past 100 days, since gain was greater than .10, if it returns -1 it didn't happen in the last 100 days.

Ed S.

JoeyVinyl
120 posts
msg #152262
Ignore JoeyVinyl
5/21/2020 10:09:38 AM

That's perfect! Thanks, Ed!

I actually searched the manual for "days(" since I knew I'd seen something like that but I couldn't find it.

nibor100
610 posts
msg #152263
Ignore nibor100
5/21/2020 11:08:21 AM

That's understandable as the SF manual was released in 2005 and the Days Since function was brought online in 2014.

Ed S.

JoeyVinyl
120 posts
msg #152264
Ignore JoeyVinyl
5/21/2020 11:11:17 AM

They haven't updated it since it was first released? Sheesh! That's just crazy!

rpgodinho
1 posts
msg #152271
Ignore rpgodinho
5/21/2020 5:04:02 PM

How to find stocks;
1) where MA(30) turns up _ (from going down to going up);
and
2) where MA(30) turns down _ (from going up to going down)

JoeyVinyl
120 posts
msg #152272
Ignore JoeyVinyl
5/21/2020 5:49:50 PM

@rpgodinho

It might be better if you started a new post so more people can see your question, but it's confusing so let me ask you what you're looking for. What I mean is that you can write something like "show stocks where ma(30) has been increasing for the last 2 days" (or however many days you want) and you'll see them. Or to see ones going down just say "decreasing" instead of "increasing."

You can't do both in the same filter, as far as I know, because they'll cancel each other out. So I'm not sure what you're asking for, but like I said, more people will see it if you put it in a new post.

xarlor
329 posts
msg #152274
Ignore xarlor
5/21/2020 8:06:08 PM

@JoeyVinyl, three places to look when trying to find commands.

1. The manual, which you noticed is not complete.

2. At the top of the site there is "Indicators". Here you would have found your days( command.

3. The forums. This one is harder, but I have found commands in the forums that were not listed in either the manual or the "Indicators" link. One example is PlotType.

snappyfrog
315 posts
msg #152278
Ignore snappyfrog
modified
5/21/2020 10:46:03 PM

rpgodinho, here is a starting point from going down to up. Reverse it for going from up to down. You can add "slope of" and number of days if you want a longer up or down before the change.

Fetcher[
price > 5
Average Volume(30) > 1000000
set{30change, count(ema(30) > ema(30) 1 day ago,1)}
and 30change > .99
and 30change 1 day ago < .99
]



JoeyVinyl
120 posts
msg #152283
Ignore JoeyVinyl
5/22/2020 4:25:04 PM

@xarlor

I didn't think about the indicator index. I usually scroll down the home page to see the list but for whatever reason I didn't think days since was there. Now I know to double check first. Thanks!

StockFetcher Forums · General Discussion · How to find the last time something happened<< >>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 2018 - 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.