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.

Scanning for moving average convergence tightening

Trying to create a scan to capture moving averages converging in a tight bunch, in this example on COUP I'm trying to capture the SMA(10), SMA(21), SMA(50), EMA(23) and EMA 65 in a tight bunch. I'm really trying to capture price of a stock on an average closing basis within 1-3% of it's 21day, 50day, 65Day closing price.
For example (screen capture) trying to capture the moving average convergence as seen around the 8 of Jan 2019


Only my 2nd time to try and create a scan. I've tried this in a few different ways , for example:

//MARKET INDICIES
[
[group is DOW30]
OR [group is SP500]
OR [group is NASDAQ100]
]
and [SMA(10 ,close) >= SMA(50,close) * 0.99]
and [SMA(10 ,close) <= SMA(50,close) * 3.01]
and [SMA(21,close) >= SMA(50,close) * 0.99]
and [SMA(21,close) <= SMA(50,close) * 3.01]
and [EMA(23,close) >= SMA(50,close) * 0.99]
and [EMA(23,close) <= SMA(50,close) * 3.01]
and [EMA(65,close) >= SMA(50,close) * 0.99]
and [EMA(65,close) <= SMA(50,close) * 3.01]
//and [volume > yesterday's volume * 1.3] // Volume up 30% from yesterday
and [PctRelative (63,$spx) > 0 ] //quarter history of outperformance


Answers

  • Also tried something like this below but not getting what I'm looking for.
    Thank you for any help provided.

    //MARKET INDICIES
    [
    [group is DOW30]
    OR [group is SP500]
    OR [group is NASDAQ100]
    ]
    and [PctDiff(close,SMA(10,close)) >= -1] //Price greater than 1% from SMA10
    and [PctDiff(close,SMA(10,close)) <= 3] //Price less than 4% from SMA10
    and [PctDiff(close,SMA(21,close)) >= -1] //Price greater than 1% from SMA21
    and [PctDiff(close,SMA(21,close)) <= 3]
    and [PctDiff(close,SMA(50,close)) >= -1]
    and [PctDiff(close,SMA(50,close)) <= 3]
    and [PctDiff(close,EMA(23,close)) >= -1]
    and [PctDiff(close,EMA(23,close)) <= 3]
    and [PctDiff(close,EMA(65,close)) >= -1]
    and [PctDiff(close,EMA(65,close)) <= 3]
    and [PctRelative (63,$spx) > 0 ] //quarter history of outperformance
  • markdmarkd mod
    edited June 2021
    If you want prices within 1% below and 3% above , use .99 and 1.03, not 3. "1.0" is 100%, so 3 is 300% (applies to the first scan).

    That might solve your problem. If not, here are other suggestions:

    Back test across many different dates, if you haven't done so already. These conditions are most likely to be true when the symbol has been ranging for period of time. Most stocks move together, so you are likely to get more hits when the market itself is ranging.

    Try the max( ) and min( ) functions to test whether the MAs have been close within some period of time, maybe a week or two - that way you conditions do not have to be ALL true on one particular date. Also, it my not be necessary to test for the very shortest MAs, since those will always be close to price.

    Also, you could use the longest term MA as the "anchor" - the shorter MAs within x per cent of the longest (slowest) MA. You almost do this in the first example, except for the last couple of lines. Probably you should also test that the longest term MA is rising (greater today than x bars ago).

    Also, for testing, I would drop the performance requirement vs. the $SPX.
  • Thank you @markd for your advice & suggestions. I've been struggling a little tonight but kind of getting results with this. I kind of don't care where the price is, if that's an option, or maybe I have to care about the price, probably yes? I kind of just want to catch the moving averages tightened close together, where the price is is not as important.

    [type = stock]
    AND [GROUP IS NOT ETF] //Excludes ETFs from scan
    AND[[exchange is NYSE] or [exchange is NASD]
    AND [Daily SMA(20,Daily Volume) > 100000]

    AND [SMA(10,close) > SMA(200,close) * 0.99]
    AND [SMA(10,close) < SMA(200,close) * 1.02]
    AND [SMA(21,close) > SMA(200,close) * 0.99]
    AND [SMA(21,close) < SMA(200,close) * 1.02]
    AND [EMA(23,close) > SMA(200,close) * 0.99]
    AND [EMA(23,close) < SMA(200,close) * 1.02]
    AND [EMA(65,close) > SMA(200,close) * 0.99]
    AND [EMA(65,close) < SMA(200,close) * 1.02]

    AND [1 DAY AGO SMA (200) > 63 day ago SMA (200) ]
    ]

  • Forgot to say that yes I've bene backtesting, in this case 603 days to Jan 8, 2019, Also attempted to try the max( ) min ( ) as you suggested but I'm guessing what I've tried here is not correct?

    [type = stock]
    AND [GROUP IS NOT ETF] //Excludes ETFs from scan
    AND[[exchange is NYSE] or [exchange is NASD]
    AND [Daily SMA(20,Daily Volume) > 100000]
    ]
    and [max(10,close) < SMA(21,close)*1.03]
    and [min(10,close) > SMA(21,close)*0.99]
    and [max(10,close) < EMA(23,close)*1.03]
    and [min(10,close) > EMA(23,close)*0.99]
    and [max(10,close) < EMA(65,close)*1.03]
    and [min(10,close) > EMA(65,close)*0.99]

    AND [1 DAY AGO SMA (200) > 63 day ago SMA (200) ]

    I seem to be getting some results close to what I'm looking for, but then I get something like this (circled in red) where the moving averages are quite a distance from each other.

  • When you are using max and min, maybe it would help to use the 5 days ago sma instead of the current sma value.

    You could also try max and min of the shorter MAs vs the long MA.
  • So this gets 13 results today (mid session).


    [exchange is NYSE] or [exchange is NASD]]

    and [
    [group is SP500]
    or [group is sp400]
    or [group is sp600]
    ]

    and [sma(200,close) > 63 days ago sma(200,close)]

    and [sma(10,close) > sma(200,close)*.98]
    and [sma(21,close) > sma(200,close)*.98]
    and [sma(63,close) > sma(200,close)*.98]

    and [sma(10,close) < sma(200,close)*1.02]
    and [sma(21,close) < sma(200,close)*1.02]
    and [sma(63,close) < sma(200,close)*1.02]

    All the results fit the criteria, BUT, they all look very different. You would think that convergence of MAs on a long term rising stock would be a winning approach, but, maybe it depends on how it happens, e.g., maybe the intermediate term MA(s) should not have crossed the long term MA recently, etc. The problem is there are so many variations for MA paths. It may be that a scan can only narrow the field from which you can choose, by other means, plausible candidates.

  • lmkwinlmkwin ✭✭
    Daryl Guppy created a multiple moving average technique where he looked for converging interests between, long term and short term investors and traders.


    https://academy.edgerater.com/guppy-multiple-moving-average-indicator-and-template/
  • @lmkwin , thanks I'll check that out.
  • Apologies @markd for this delayed response, regular job took over, just getting back to this now. Thank you for your suggestions there and for your example, this definitely helps and yes I will have to use it as part of a selection, I had noticed during the week the results I was getting that not all results were suitable. I will take a look at your code suggestions, play with that and I will let you know. Thank you kindly.
Sign In or Register to comment.