StockFetcher Forums · General Discussion · count occurences , help needed<< >>Post Follow-up
ludowillems
111 posts
msg #149421
Ignore ludowillems
modified
10/26/2019 7:49:58 AM

Dear all,
I am looking for a filter that returns the number of occurences of a series of 3,4,5,6,7,8,9 green(or red) candles over the last n-days. If for example, the filter returns only one occurence of a series of n-candles in the last n-days (lets say 1000 days, appr. 3 years) there is a great probability that the next candle will be of the opposite color.
so far I managed to identify a series:

Fetcher[
set{daily_diff, close - open}
show stocks where daily_diff has been below 0 for the last 5 days
and open has been decreasing for 5 days
]


Many thanks for your time.
Ludo


xarlor
581 posts
msg #149430
Ignore xarlor
10/26/2019 2:42:49 PM

As an example this will show you stocks that had 9 straight green candles in a row. It ill also show you a histogram of the number of green candles in a row.

Fetcher[
set{var1,count(close > open,9)}
var1 > 8
]



If you prefer an oscillator instead of a histogram:

Fetcher[
chart-time is 1 year
set{var1,count(close > open,9)}
var1 > 8
draw var1 line at 9
]



ludowillems
111 posts
msg #149433
Ignore ludowillems
10/27/2019 6:58:30 AM

Thank you Xarlor. I managed to add a column that counts the number of occurences. But there seems to be a limit in number of days in history.
Fetcher[
chart-time is 3 year
set{var9,count(close > open,9)}
var9 > 8
draw var9 line at 9
add column count(var9 > 8,250)
]



xarlor
581 posts
msg #149437
Ignore xarlor
10/27/2019 3:10:01 PM

Yes, SF has a limit of 1 year's worth of trading days (252 days) on any single indicator. You have to do some trickery to include multiple years.

Here is your filter that gives the number of times there have been 9 green candles in a row within the last 4 years (1008 trading days). A result of 1 means this is the first time it has happened in 4 years. The results are sorted from lowest number of occurrences to highest.


Fetcher[
chart-time is 3 year
set{var9,count(close > open,9)}

set{y1,count(var9 > 8,252)}
set{y2,count(var9 1 year ago > 8,252)}
set{y3,count(var9 2 years ago > 8,252)}
set{y4,count(var9 3 years ago > 8,252)}

set{z1,y1 + y2}
set{z2,z1 + y3}
set{z3,z2 + y4}

var9 > 8

add column y1
add column y2
add column y3
add column y4

add column z3 {No times in last 4 years}

draw var9 line at 9

sort by column 9 ascending
close 3 years ago > 0
]



ludowillems
111 posts
msg #149460
Ignore ludowillems
10/28/2019 10:26:44 AM

Great job! thanks for your time!
Ludo

SAFeTRADE
644 posts
msg #149465
Ignore SAFeTRADE
10/28/2019 11:01:33 AM

You can only have count occurrences up to 100.

From Stockfetcher indicators:


Count -- Occurrences

Parameters Indicator,period
Period Limit 100
Usage count(indicator,length)

Hope this helps

ludowillems
111 posts
msg #149470
Ignore ludowillems
10/28/2019 11:45:27 AM

thanks safetrade !

StockFetcher Forums · General Discussion · count occurences , help needed<< >>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.