StockFetcher Forums · General Discussion · What would the coding be for this condition?<< >>Post Follow-up
smartguy
47 posts
msg #149933
Ignore smartguy
12/19/2019 6:00:32 PM

How would I code this condition- "SPY has closed BELOW its 10-day simple
moving average for at least 10 days". Thanks in advance for any help with this.

Village Elder
231 posts
msg #149934
Ignore Village Elder
12/19/2019 6:28:10 PM

Out of the last x days?

Try this:

Fetcher[
symlist(spy)
count(ind(SPY,close) below ind(SPY,MA(10)),10) above 9
]



This will trigger when the SPY close has been below the MA(10) last each of the last 10 days

Or maybe you want something like this:

Fetcher[
symlist(spy)
count(ind(SPY,close) below ind(SPY,MA(10)),20) above 9
]



In this case, all that is required is that the SPY close below its MA(10) on at least 10 of the last 20 days, with no requirement as to when or in any order. Hope this helps.

smartguy
47 posts
msg #149935
Ignore smartguy
12/19/2019 6:34:35 PM

That was very helpful, and thank you for such a fast response. One more followup question. Instead of SPY, say I wanted a list of ETF's.This is actually only one line of what I am trying to accomplish, and I would like to be able to apply to all ETF's, or at least a list of actively traded ones. How would I change what you shared? Thanks again.

push5280
197 posts
msg #149936
Ignore push5280
modified
12/19/2019 6:48:25 PM



Fetcher[
market is etf
count(ind(SPY,close) below ind(SPY,MA(10)),20) above 9
]



smartguy
47 posts
msg #149937
Ignore smartguy
modified
12/19/2019 6:56:14 PM

yes, but I want the ETF to be the one tracked,not always the SPY. Meaning I want each ETF that closed BELOW its 10-day simple moving average for at least 10 days not just in relation to SPY. I want a list of ETF's that satisfy the condition. I used SPY simply as an example of an ETF.

xarlor
562 posts
msg #149938
Ignore xarlor
12/19/2019 7:44:42 PM

Last 10 consecutive daays:

Fetcher[
market is etf
close < ma(10) for last 10 days
]



Any 10 out of last 20 days. Or replace 20 with how many days you want to look back:

Fetcher[
market is etf
set{var1,count(close < ma(10),20)}
var1 > 9
add column var1
sort column 5 descending
]



smartguy
47 posts
msg #149939
Ignore smartguy
12/19/2019 8:54:50 PM

Right on, that's the ticket. Thank you

StockFetcher Forums · General Discussion · What would the coding be for this 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.