StockFetcher Forums · General Discussion · counting the number of crossovers<< >>Post Follow-up
se
3 posts
msg #161139
Ignore se
6/10/2024 4:57:03 PM

Can StockFetcher be used to count the number times that the 8 day MA crossed over or below the 21 MA in the last 60 days, and display the number of such crossovers in a new column with add column
Thanks, Steve : new to stockFetcher

nibor100
1,045 posts
msg #161140
Ignore nibor100
6/11/2024 12:17:39 PM

Welcome to SF!

The short answer is, Yes.

So now, do you want to take a shot of writing that filter yourself, first and if it doesn't do what you want paste it here so we can take a look at it? (that is the best way to learn filter coding in SF)

Ed S.


lis
37 posts
msg #161141
Ignore lis
6/11/2024 1:32:51 PM

And, hint: Stockfetcher provides examples of indicators and measures, along with examples of how to use them:

https://www.stockfetcher.com/forums/Indicators

Count -- Occurences is one of those:

https://www.stockfetcher.com/forums/Indicators/Count-Occurrences/34492

Mactheriverrat
3,157 posts
msg #161143
Ignore Mactheriverrat
6/11/2024 9:23:50 PM

Submit
Fetcher[
Draw ma(8)
Draw ma(21)
chart-time is 7 months

/* m8m21 is number of consecutive days MA(8) above (+)/below(-) previous MA(21) */
set{m8m21b,days( ma(8) is above ma(21) ,250)}
set{m8m21a,days( ma(8) is below ma(21) ,250)}
set{m8m21, m8m21a - m8m21b} and add column m8m21 {m8m21}

Set{cntm8m21a,count( MA(8) > MA(21) ,1)}
draw cntm8m21a

Set{cntm8m21b,count( MA(8) < MA(21),1)}

draw cntm8m21b
]



wantonellis
161 posts
msg #161146
Ignore wantonellis
6/12/2024 2:08:06 PM

Fetcher[
ma(8) crossed above ma(21) with the last 60 days
draw ma(8)
draw ma(21)
set{ma_crossed, count(ma(8) crossed above ma(21),60)}
add column ma_crossed
set{ma_signal, count(ma(8) crossed above ma(21),1)}
draw ma_signal
]



nibor100
1,045 posts
msg #161150
Ignore nibor100
6/18/2024 2:23:37 PM

@se/Steve,

Since you wanted a total column of both up and down crossovers, I coded the filter below borrowing from all 3 other respondents and have provided some alternative ways to display the counts.

Ed S.

Fetcher[
Draw ma(8)
Draw ma(21)
chart-time is 61 days

set{8crossup21, count(MA(8) crossed above MA(21),60)}
set{8crossdown21, count(MA(8) crossed below MA(21),60)}

set{SumXupandXdown, 8crossup21 + 8crossdown21} add column SumXupandXdown
add column 8crossup21 draw 8crossup21
add column 8crossdown21 draw 8crossdown21

set{var3, 8crossup21} draw var3 Legend{var3, 8crossesesup21} PlotType{var3,dot}
draw var3 line at 0
set{var4, 8crossdown21} draw var4 Legend{var4, 8crossesdown21} PlotType{var4,dot}
draw var4 line at 0

m8m21 is number of consecutive days MA(8) above (+)/below(-) previous MA(21)
set{m8m21b,days( ma(8) is above ma(21) ,250)}
set{m8m21a,days( ma(8) is below ma(21) ,250)}
set{m8m21, m8m21a - m8m21b} and add column m8m21 {m8m21}
Set{cntm8m21a,count( MA(8) > MA(21) ,1)}
draw cntm8m21a
Set{cntm8m21b,count( MA(8) < MA(21),1)}
draw cntm8m21b
sort column 5 descending
draw m8m21 PlotType{m8m21,zerobar}
]



StockFetcher Forums · General Discussion · counting the number of crossovers<< >>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.