New Members: Be sure to confirm your email address by clicking on the link that was sent to your email inbox. You will not be able to post messages until you click that link.

Percent change syntax

I am having difficulty in drawing a scan for percent change. The scan I would like to draw is for a percent change over the last year of say 200% from low to high. If anyone can help, it would be greatly appreciated. Thank you.

Comments

  • lmkwinlmkwin ✭✭
    edited October 2021
    go to the advanced scan workbench in StockCharts and select the PctChange from the Technical Indicators dropdown.

    Of course, first select a universe of stocks to scan, like the SP500, for example, and/or other security limitations.

    Then add your PctChange criteria.

    It will default into your scan like this

    and [PctChange(10,close) > 10]

    You would change the period from 10 as in 10 days, to what period you want. The > 10 is greater than 10 percent, so you'd change that to 200 if that is what you want. Close can be changed to Low, or High but it's looking at the beginning price, be it close, high, low or open, and comparing it to current last as it is written.

    If you run into an issue, post your code here for assistance.
  • markdmarkd mod
    edited October 2021
    You can express the extreme prices over a period of time using the min( ) and max( ) functions.

    So the lowest price over the last month (21 trading days) would be

    min(21, low)

    and the highest price over the same period would be

    max(21, high)

    A year is approximately 251 trading days (52 weeks x 5 days = 260 days - 9 market holidays = 251).

    In a scan, per cents are expressed as decimals. So, 1.0 is 100%, 80% would be .8, 125% would be 1.25.

    A per cent has to be expressed in terms of a base value or a denominator. For instance, if price advances from a low of 5 to a high of 7, the difference from low to high is 2 points. So the low is the base value (the denominator) and the gain (the difference) is the numerator. So, the per cent gain is 2/5 or .4 or 40%.

    In your case, you want the gain (high minus low) to be twice (200%) the low.


    So, applying the rules of syntax for the scan engine, you would write:

    and [ [max(251, high) - min(251, low)] / min(251,low) > 2]

    Note that you use brackets [ ] not parentheses ( ) to group numbers in an arithmetic expression.
Sign In or Register to comment.