StockFetcher Forums · General Discussion · Count Days below a Fixed Price<< >>Post Follow-up
jjmcguire
22 posts
msg #158238
Ignore jjmcguire
12/26/2021 7:20:11 PM

How can I count the days below a fixed value similar to the price line value?

This code won't work, but I am wanting something like this that counts the days that are below a fixed value such as the low 60 day low as of today:

Fetcher[
apply to symlist(MSFT)

set{MinLow, Low 60 Day Low}
draw price line at MinLow

/*then count the days below the price line value */
set{BelowMinLow, count(close below price line at MinLow, 1)}
draw BelowMinLow

chart-time is 1 year
]



Below the chart I simply want to see if the close price is below the price line value (MinLow on today) or not. Any assistance is much appreciated.

Thanks!
Jason

Cheese
1,374 posts
msg #158241
Ignore Cheese
modified
12/26/2021 10:22:43 PM

https://www.stockfetcher.com/forums/General-Discussion/Count-Days-below-a-Fixed-Price/158238
======================

This example by TRO might give you something close to what you might be looking for:

https://www.stockfetcher.com/forums/General-Discussion/how-to-find-lowest-low-over-X-number-of-days/98517
TheRumpledOne modified 1/10/2011 9:50:32 AM


nibor100
1,010 posts
msg #158242
Ignore nibor100
12/27/2021 1:36:35 AM

First, you don’t need “ price line at“ in your second set.statement.
Secondly I don’t believe you will ever find a daily close in the last 60 days below the low 60 day low unless I’m missing something.
Ed S

Mactheriverrat
3,135 posts
msg #158244
Ignore Mactheriverrat
12/27/2021 11:34:42 AM

@Ed S

I was thinking the same thing about finding stocks below the 60 day low.

He could try
show stocks at low 60 day low

Then watch at stocks go lower.

Same as
show stocks at high 60 day high

Then watch at stocks go higher.


jjmcguire
22 posts
msg #158245
Ignore jjmcguire
12/27/2021 11:55:44 AM

Hi Nibor, I am wanting to compare the close from any time period to a value that is derived only from today (similar to how price line does it). So if the price line (calculated as the 60 day low for example) is at $280 for MSFT, then I want to compare that value to the close from historical time periods, ie. 70, 80, 90 days ago close compared to the price line value.

The price line value is not a set, but a value that is only applicable to today. If I use a Low 60 day low instead of price line, then that value is different for all historical time periods, which is not what I want. I want to compare historical close prices to the only the Low value measured from today, but unfortunately I am not able to use the Price Line in any calculations.

Thanks!
Jason

nibor100
1,010 posts
msg #158247
Ignore nibor100
12/27/2021 4:50:57 PM

Jason,

I'm following you better now, but depending on your specific uses of past closes in comparison to a set numeric value from today SF has limitations since it processes data in order from the past to the present.

So, assuming the count function returns 25 closes > than your numeric value from today.

what then do you need to know or do with those 25 different closes?

thanks,
Ed S.

nibor100
1,010 posts
msg #158252
Ignore nibor100
12/27/2021 10:25:17 PM

here are some example codes of options you can play around with:

Fetcher[
apply to symlist(MSFT)

set{MinLow, Low 60 Day high} add column minlow
draw price line at MinLow

chart-time is 1 year

add column count(close > minlow,70)

set{var, count(close > minlow,70)} draw var
add column days(close 15 days ago > minlow,70)
set{var1, days(close 15 days ago > minlow,70)} draw var1
]



the code below uses the rarely used VarOffset function to retrieve specific past values using a variable, perhaps with mods it can work for you.

Ed S.

Fetcher[
apply to symlist(MSFT)
SET{d2swlo,COUNT(LOW 2 DAY AGO ABOVE LOW 1 DAY AGO,1)}
SET{d1swlo,COUNT(LOW 1 day ago ABOVE LOW ,1)}
SET{swlo,d1swlo * d2swlo} add column swlo draw swlo
set{swlod, days(swlo equals 1,20)} add column swlod {days since swing low} draw swlod

set{hi1st, VarOffset(high,swlod)} add column hi1st
set{hi2, VarOffset(high 1 day ago,swlod)} add column hi2
set{CountBackLine, VarOffset(high 2 day ago,swlod)} add column CountBackLine
draw price line at CountBackLine
]



jjmcguire
22 posts
msg #158264
Ignore jjmcguire
modified
12/28/2021 12:06:34 PM

Thanks Nibor and Cheese. I haven't been able do what I am wanting from the code you provided although the code has been helpful for other things.

Here is an example of how I want the chart to display:

Fetcher[
apply to symlist(MSFT)

set{MinLow, Low 60 Day Low}
draw price line at MinLow

/* on 12/28/2021 the 60 day min low is 280.3 */
set{BelowMinLow, count(close below 280.3, 1)}
draw BelowMinLow

chart-time is 1 year
]



The BelowMinLow shows every day that the close is below the 60 day low taken on 12/28/2021. I can't use a fixed value for my scan, but I included it so you can see what I'm looking for in the final chart.

In this example, I'm trying to identify the lower portion of the yearly chart so I can then filter for interesting events happening in that region.

Thanks,
Jason

StockFetcher Forums · General Discussion · Count Days below a Fixed Price<< >>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.