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.

How do I program a scan to ask for comparative closing values of the immediately prior day??????????

I see no way to ask for values of the prior day (or any series of prior days) in any of the scan component boxes. How then, would I program the following????

(For the daily charts) Where I want to see instances of an INCREASE in the difference between(today's closing PPO Signal Line Value - today's
closing PPO line value) and (yesterday's closing PPO Signal Line Value - yesterday's PPO Line Value)???????

(Also for the daily chats) Where I want to see instances of an INCREASE in the difference between(today's closing Minus DI - today's closing Plus DI)
and (yesterday's closing Minus DI - yesterday's closing plus DI) ??????

Answers

  • markdmarkd mod
    edited August 24
    Just to clarify - the scan engine returns only symbols, not values. However, when you write your scans, you ARE comparing values - values of indicators or calculations or prices or constants. The scan engine returns the symbols that meet the comparisons (greater than, less than, equal, between) of values that you specify.

    So for your first comparison, I think you can use PPO Hist. PPO Hist (Hist short for histogram - the bars extending above and below the 0 line on the indicator panel) is the difference between Line and Signal (same as MACD Hist).

    So, you would test for today's Hist > yesterday's Hist.

    PPO is explained here (if you need it):

    https://school.stockcharts.com/doku.php?id=technical_indicators:price_oscillators_ppo

    The PPO and PPO Hist syntax is here (about 2/3 down the page):

    https://support.stockcharts.com/doku.php?id=scans:indicators

    So it would be

    [PPO Hist(12,26,9) > yesterday's PPO Hist(12,26,9)]
  • markdmarkd mod
    edited August 24
    For ADX, I think you need to use the absolute value function absval( ) to compare the difference between Plus DI and Minus DI, like this:

    and [AbsVal(Minus DI(14)-Plus DI(14)) > AbsVal(yesterday's Minus DI(14)- yesterday's Plus DI(14))]

    If you don't use absolute value, and you get negative numbers for the operation "DI- minus DI+", then the greater than operator ">" could give you unintended results. For instance, if yesterday's difference was +2 and today's difference is -5, that should be a hit because the distance between DI- and DI+ is greater today. But, on the number scale, +2 is greater than -5, so the scan would skip it, unless you use absval( ).

    All the scan engine's functions (like AbsVal, min, max, etc.) are documented here:

    https://support.stockcharts.com/doku.php?id=scans:functions
  • Actually, Mark,--it does answer it to a great degree. But where or where are commands such as YESTERDAY documented???? Nowhere to be seen in any of the material I've been able to review at the site. And what if I wanted to evoke values for the day BEFORE yesterday, and so on, for comparative purposes????
  • markdmarkd mod
    edited August 26
    The "door way" to understanding all of Stockcharts is the Chart School link on the main menu at the top the Members page (the page you get when you sign in). I'm guessing you've already looked at this, but for others:

    https://school.stockcharts.com/doku.php

    About half way down that page is the Scanning Resources box with links to Scanning Documentation, Scanning Tutorials and the Advanced Scan Library.


    https://support.stockcharts.com/doku.php?id=scans

    https://support.stockcharts.com/doku.php?id=scans:tutorials

    https://support.stockcharts.com/doku.php?id=scans:library

    I think it's probably most helpful to look through the sample scans first - especially the "pre-defined" scans to look for syntax you might want to use.


    As for your specific question, I can't find where time offsets are documented, either. So here's how it works:

    The basic format is "x time units ago" placed in front of the indicator or price, e.g. "2 days ago MACD Hist(12,26,9)".

    Time units available are: days, weeks or months.

    The "x" in "x time units ago" has to be a digit or digits, NOT the number spelled out, e.g. "3 days ago close ", not "three day ago close".

    The exception to the digits only rule is, in the daily time frame you can say "today's" or "yesterday's". You can also say "1 day ago". But you cannot say "last month" or "this week".

    ALSO if the time unit is weeks or months, you have to add a corresponding modifier before the indicator or price, e.g. "6 weeks ago weekly close", or "1 month ago monthly RSI(14)". If there is no modifier in front of the indicator or price, the scan engine ASSUMES you mean daily (so a phrase like "6 weeks ago close" may pass syntax but will give unpredictable results - it has to be "6 weeks ago weekly close". -- if you wanted the daily close from 6 weeks ago you would say "30 days ago close" - 6 weeks x 5 trading days in a week = 30 )


    So here are some examples:

    Monthly

    and [1 month ago monthly MACD Line(12,26,9) > 2 months ago monthly MACD Line(12,26,9)]

    Weekly
    and [1 week ago weekly MACD Line(12,26,9) > 2 weeks ago weekly MACD Line(12,26,9)]

    Daily
    and [1 day ago MACD Line(12,26,9) > 2 days ago MACD Line(12,26,9)]

    NOTE: The counting method for "units ago" assumes the current bar (e.g. today) is bar 0, the preceding bar is 1 bar ago (meaning 1 day ago, 1 week ago, 1 month ago) etc. Note that the "current" bar refers to the most recent final close if the markets are closed, OR, the most recent INTRADAY update if the markets are open (but, if you are running your scan when the markets are open, you can use the drop down above the scan window to specify whether to use the last close or the most recent update from the session in progress for the "current" bar).

    NOTE: If you run a weekly scan on say, Wednesday, the scan engine will use the most recent update (or last daily close, if you specified that in the drop down) as the CLOSING value for the current week - even though the week is not over yet. And, the scan engine will use the most recent completed week's closing values (i.e from the preceding Friday's close) for "1 week ago weekly close" or "1 week ago weekly RSI(14)". So current week in progress is bar 0, most recent completed week is 1 bar ago. The same idea applies to monthly scans.

    The consequence of this is, if you use a weekly or monthly scan as a trigger ( a signal to enter or close a position), and you run it mid week or mid month, you may get hits, but by the end of the week or month, those hits might go away as values change.


    NOTE: A little off topic, but related: for some functions, like ema( ), sma( ), max( ), min( ), in addition to the modifier preceding the function, you also need to add a time frame modifier to some parameter values. For instance:

    and [weekly ema(5, weekly close) x weekly ema(21, weekly close)]

    ...

    and [weekly max(10, weekly RS(14)) > 80]

Sign In or Register to comment.