StockFetcher Forums · Announcements · New Feature: Occurrences -- Count()<< 1 2 >>Post Follow-up
stockfetcher
980 posts
msg #27374
7/15/2003 3:09:19 PM

This is a new screening feature which allows you to create screens based on how many times a particular screening event occurs. As a basic example, suppose you are interested in stocks that have set multiple 1 year highs over the last 30 days:

Fetcher[Show stocks where the count(high reached a new 1 year high, 30) is above 10]



In the example above the count(...) phrase tells StockFetcher to return the number of times a stock has set the 1 year high over the last 30 days.

Syntax:

count(screening phrase , period)


Current Limitations:

  • You can only include a single screen within the count(...) text. That is, you can't include filters which have been joined with "and" inside of the count(...) text.
  • There is a limit of 100 days for accumulating the counts. This restriction is based on performance and hopefully we will be able to increase that value.
  • Weekly measures are not fully supported within the count() phrase.

    Additional Examples:

    Cases where the MA(10) has not crossed below the MA(50) in the last 60 trading days.
    Fetcher[show stocks where the count(MA(10) crossed below MA(50),60) is below 1]



    The CCI(14) has spent exactly 20 of the last 90 trading days below -100.
    Fetcher[show stocks where the count(CCI(14) below -100,90) equals 20]



    Display a column which shows the number of times the high has crossed above the upper Bollinger Band in the last 15 days. (You can sort on the resulting column.)
    Fetcher[
    show stocks where the close is between 4 and 100
    and draw Bollinger(20)
    and add column count(high crossed above the upper Bollinger Band(20), 15)
    ]



    *** Advanced example *** Find stocks where the RSI(14) has spent more than 75% of the time either above 70 or below 30 within the last 45 days.

    Fetcher[
    set{var1, count(rsi(14) is below 30, 45)}
    set{var2, count(rsi(14) is above 70, 45)}
    set{sum1, var1 + var2}
    set{ratio2, sum1 / 45}
    show stocks where ratio2 is above 0.75
    and draw rsi(14)
    and draw rsi(14) line at 30
    and draw rsi(14) line at 70
    ]



    As always, if you notice any bugs with this new feature, or have any questions about it, please don't hesitate to let us know!

    Thank you,

    StockFetcher.com Support



  • zfetch
    16 posts
    msg #27381
    Ignore zfetch
    7/15/2003 7:02:25 PM

    I like the count feature, and tried to include a variable within the count(...) text. This may be used to count the occurances of events for a specific measure.

    That didn't work for the filters tried, so it may be a current limitation for items in within the count(...) text. Could the use of variables in the count statement, be added at some time, to the count function?

    Thanks,
    zfetch



    tomb
    267 posts
    msg #27506
    Ignore tomb
    7/21/2003 3:24:45 PM

    Hi,

    If possible, could you provide an example that doesn't seem to recognize a variable within the 'count' phrasing. We will definitely look into this further!

    Thank you,

    Tom
    StockFetcher.com Support



    zfetch
    16 posts
    msg #27513
    Ignore zfetch
    7/21/2003 11:40:41 PM

    In the example 1, there is a ratio of a recent high divided by a previous x-day high. The count function counts the occurances where the ratio is between a low and a high.
    In the example 2, the count function counts the occurances where the ratio is near a single value.
    Example 1 didn't work, and example 2 did work.
    The problem could be the use of "between" in a count statement, and not a problem with the variable.




    Ex. 1
    Fetcher[
    and draw ratio2
    and draw cnt

    set{ h15dh, high 15 day high 1 days ago }
    set{ ratio2, high / h15dh }
    set{ cnt , count( ratio2 is between 0.96 and 1.04, 20)}

    and close is between 1 and 5 and avgvol(5) multiplied by close is above 80000
    ]



    Ex. 2
    Fetcher[
    and draw ratio2
    and draw cnt
    set{ h15dh, high 15 day high 1 days ago }
    set{ ratio2, high / h15dh }
    set{ cnt , count( ratio2 is near 1, 20)}

    add column cnt
    and sort column 5 descending

    and close is between 1 and 5 and avgvol(5) multiplied by close is above 80000
    ]




    tomb
    267 posts
    msg #27514
    Ignore tomb
    7/22/2003 10:20:54 AM

    Hi,

    Thank you for the examples. There was definitely a bug on our end and that should be resolved now. Please let us know if you continue to have any problems with the examples, or have any other questions or comments.

    Thank you again!

    Tom
    StockFetcher.com Support



    TheRumpledOne
    6,411 posts
    msg #32232
    Ignore TheRumpledOne
    6/2/2004 8:17:09 PM

    I need to be able to do the following:

    if x = 1, set y = 10
    if x = 2, set y = 15
    if x = 3, set y = 19

    Is there a way? Have I missed/forgotten something?

    If not, can you write us a WHEN command:



    SET{WHEN(X,1,Y,10)}

    SET{WHEN(X,2,Y,15)}

    SET{WHEN(X,3,Y,19)}

    If you don't like then name WHEN, I don't care what you call it.

    THANKS FOR YOUR CONSIDERATION.




    cegis
    235 posts
    msg #32245
    Ignore cegis
    6/3/2004 2:10:37 PM

    TheRumpledOne,

    You're looking in the right place! Try:

    set{y1,10 * count(x=1,1)}
    set{y2,15 * count(x=2,1)}
    set{y3,19 * count(x=3,1)}
    set{ya,y1 + y2}
    set{y,ya + y3}

    Interpretation:

    In Line 1, count(x=1,1) will equal 1 if the condition is true, or zero otherwise. Therefore y1 will equal 10 if x=1, otherwise it'll equal zero. Same thing is used for y2 and y3. Since the three conditions are mutually exclusive, you can just add y1, y2, and y3 to get your answer.

    To put this in an illustrative filter:

    Fetcher[
    set{y1,10 * count(price is less than 5,1)}
    set{y2,15 * count(price is between 5 and 10,1)}
    set{y3,19 * count(price is greater than 10,1)}
    set{ya,y1 + y2}
    set{y,ya + y3}

    price between 4 and 11
    and volume 30 day low is greater than 1000000

    add column y1
    add column y2
    add column y3
    add column y
    ]



    HTH,

    C




    TheRumpledOne
    6,411 posts
    msg #32250
    Ignore TheRumpledOne
    6/3/2004 2:44:27 PM

    Thanks CEGIS...

    Of course, duh! LOL!!

    I appreciate your time and effort.

    MAY ALL YOUR FILLS BE COMPLETE.


    cegis
    235 posts
    msg #32251
    Ignore cegis
    6/3/2004 2:50:39 PM

    Glad I could help.

    This technique is a good thing to point out in this thread anyway. Although not quite as "clean" as an IF(cond,val if true,val if false) function, count(cond,1) provides ALL of the same capabilities.

    C


    TheRumpledOne
    6,411 posts
    msg #32252
    Ignore TheRumpledOne
    6/3/2004 3:05:07 PM

    CEGIS

    Please email me...

    THERUMPLEDONE@HOTMAIL.COM

    Thanks



    StockFetcher Forums · Announcements · New Feature: Occurrences -- Count()<< 1 2 >>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.