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.
Options

need help with this weekly scan....

Smyles61Smyles61
edited December 2015 in Scanning
The syntax I am trying to write is for this line...
"The last 10 or more weekly closings are less than the 30 week SMA"

Answers

  • Options
    markdmarkd mod
    edited December 2015
    If I remember correctly @Gord 's answers about using MACD to compare MAs and closes - if you are OK with an EMA instead of an SMA, you could write

    and [max(10, MACD Hist(1,30,0)) < 0]

    Add MACD Hist(1,30,0) to a chart, along with a 1 period EMA and a 30 period EMA to verify the results.

    The first two parameters are the lengths of two EMAs (MACD only takes EMAs). The third parameter is an average of the difference between the two emas If that third parameter is 0, the indicator displays just the raw difference between the first two emas. As long as that difference is above zero, the first EMA (1) is above the second (30) EMA; if the difference is below zero, the first is below the second (this assumes the first EMA is the shorter EMA).

    A 1 period EMA is the same as the close, so this combination of EMAs will display the difference between the close and the EMA.

    So the above scan says the maximum difference between the two EMAs (1 and 30) has not exceeded 0 for the last 10 periods. Remember we are dealing with negative numbers, so "smaller" negative numbers are actually greater, e.g. -5 is greater than -10, so we have to use max() even though the Hist bar for -5 would be shorter than -10 on the indicator display.

  • Options
    Sorry, that should be

    and [max(10, weekly MACD Hist(1,30,0)) < 0]
  • Options
    Markd, great explanation, although one update.

    I don't run weekly scans very often so I get caught on this one too.

    We need to add "weekly" in front of MAX. The default is always "daily", so without that qualifier we are asking for the weekly MACD to be less than 0 for the last 10 daily periods, not the last 10 weekly periods.

    I know this sounds a little strange but the weekly MACD does have a daily value, (ie an intra-week value), you will get a different value on Monday, Tuesday, Wed etc, then at the end of the week it has a set weekly value.

    Also a reminder to all, its best to run these weekly scans on the weekend to avoid the intra-week data, unless that's what you want.
  • Options
    @gord - thanks for pointing that out. I normally do modify everything for the time frame in question, but I didn't know for sure whether it was overkill. Guess not!
Sign In or Register to comment.