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.

Moving averages high, low scanning

Here is the link to what I am looking for:

Here is the part of my scan that doesn't seem to give intended results:

and [SMA(8, low) < SMA(10, high)]
and [3 days ago low < SMA(10, high)]
and [2 days ago low > SMA (10, high)]
and [low > SMA (10, high)]

Low of the MA 8 is below high of SMA 10
3 days ago the low of the bar is below (or touching) the high of SMA 10
2 days ago, the low of the bar is above the high of SMA 10
today low of the bar is above the high of SMA 10.

No syntax error, but not much results either!

Is this the correct way to input for high and low of a moving average?
Any ideas on what is wrong with that setup?

Thanks for any help!


  • Options
    markdmarkd mod
    edited July 2020
    sma(8, low) is the sma of the last eight low values from each bar. sma(10, high) is the average of the last 10 highs.

    If you want a low value over some period, use min( ), as in min(8, sma(8, close)) - note - two sets of parens, because you are putting one function inside another; each function needs its own set.

    For the high value over some period, use max( ), as in max(10, sma(10, high)).

    I think you can figure out the rest. If not, post what doesn't work again.
  • Options
    edited July 2020
    Tried it like this and it didn't work:

    and [min (8, SMA(8, low)) < max (10, SMA(10, high))]
    and [3 days ago low < max (10, SMA (10, high))]
    and [2 days ago low > max (10, SMA (10, high))]
    and [low > max (10, SMA (10, high))]

    I tried to replace "low" to "close" in min (8, SMA (8, close))
    I get too many hits but not what I am looking for.

    (And thanks for your help!)
  • Options
    markdmarkd mod
    edited July 2020
    did you try it this way?

    and [min (8, SMA(8, close) < max (10, SMA(10, close))]
    and [3 days ago low < max (10, SMA (10, close))]
    and [2 days ago low > max (10, SMA (10, close))]
    and [low > max (10, SMA (10, close))]

    maybe also try 3 days ago close, instead of 3 days ago low, and same for 2 days ago.

    Also, if you are getting too many hits, but you think the set up is worthwhile, limit your universe say to an index, like sp100 maybe or nasdaq 100.
  • Options
    Just did. Some results look valid, but others are not. Check

    is not a valid one. Yet this one: is valid.

    There was typo on the first line that should read:
    and [min (8, SMA(8, close)) < max (10, SMA(10, close))]
    missing a closing parenthesis after the first "close".

    That scan is a good starting point, but still doesn't seem to fit the bill!
  • Options
    I see. Well, your charts have the averages of the highs and lows, and my version of the scan would have the averages of the closes. So the results of that scan wouldn't necessarily be right on your charts.
  • Options
    Moving averages can be set up to get either the low, close, open or high.
    How come I can't scan for something (simple) as the MA 8, low or MA 10, high?
  • Options
    you can. your original scan should have done it.

    what did you mean by not much results - not many hits?
  • Options
    Running the scan now, I get 208 results. I didn't go through all of them.
    And some should not appear on the list, like that one:
    as no recent bars are touching MA 10, high
  • Options
    If you don't mind, post the code that got you 208 results, if you still have it.

    Usually the reason for "invalid" results is a line that is not executing, but does not give a syntax error. You could explore this by commenting out each line one at a time. Time consuming, but usually works. Also, try running it against a small index, like sp100, so you get more manageable results.

    Also, I'm still not sure I understand exactly what you are looking for. I thought I knew, but maybe not.
  • Options
    Let me work on it, and I'll come back if needed.
Sign In or Register to comment.