StockFetcher Forums · Filter Exchange · How to count when two separate criteria are met?<< >>Post Follow-up
Marco Sicily
20 posts
msg #136196
Ignore Marco Sicily
6/5/2017 7:35:14 PM

Hello Everyone,

I'm interested in a work around for the SF limitations using the Count feature. I know that SF does not support using 2 or more criteria in a "Count" filter phrase but I'm thinking someone out there has devised a workaround solution.

I am trying to count how many times in the last 100 days a specific symbol has had both the high of the day be > 0.50% above the open and the low of the day be > 0.50% below the open. It's easy enough to code to discern how many times either criteria been met but I haven't been able to develop code to see how many days that both the high and low criteria are met.

Thanks in advance for your help.

Marco

four
5,087 posts
msg #136198
Ignore four
6/5/2017 7:49:46 PM

Take a look here:
http://www.stockfetcher.com/forums2/General-Discussion/and-in-count-function/83330/-1/83332

Marco Sicily
20 posts
msg #136199
Ignore Marco Sicily
6/5/2017 10:48:48 PM

Thanks "four" for your help ! I had previously reviewed that post and it seems to explain how to code to find out if two conditions are met. What I can't figure out is how to then discern how many times in 100 days that both conditions were met. That is what I am most interested in. I didn't see in Kevin's or TRO's code that answer but maybe I'm missing something obvious.

These two lines of my code tell me how many times each condition was met in the last 100 days:

add column count(high more than .50 percent above open, 100) { high >.50% above open}

add column count(low more than .50 percent below open, 100) {Low > .50% below open}

Now I need to figure out how to find out how many days in the last 100 days that both conditions were met on the same day.

four
5,087 posts
msg #136200
Ignore four
modified
6/5/2017 11:38:42 PM

Perhaps an example to work with...

Fetcher[
/* TASK:
Determine relationship of ma(10) to open and close
Identify as true when above ma(10) and false when below ma(10)
Then identify when both are above on the same day
Then identify when both above on the same day during last 100 days
*/
draw ma(10)
/*
1 = true and 0 = false
Following combinations may occur:

true true 1,1 1+1=2

false false 0,0 0+0=0
false true 0,1 0+1=1
true false 1,0 1+0=1
*/
/*Indicate 1 or 0 for condition*/
set{ma_10cls, count(close > ma(10),1)}
draw ma_10cls
/*Indicate 1 or 0 for condition*/
set{ma_10opn, count(open > ma(10),1)}
draw ma_10opn
/*Add both conditions*/
set{both, ma_10cls + ma_10opn}
draw both
/*Count how many times in last 100 days both conditions met on same day*/
set{both2, count(both equals 2,100)}
add column both2
]



four
5,087 posts
msg #136201
Ignore four
modified
6/5/2017 11:56:57 PM

Click on image to zoom [new window will open]
This chart area in color shows all false... conditions are not met... no "boxes" are drawn
Close and Open below ma(10) for these days... all set statements return 0


StockFetcher Forums · Filter Exchange · How to count when two separate criteria are met?<< >>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.