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 to find stocks just before they Crossover (Moving Avg. or MACD)

I would like to build a scan that detects possible crossovers just before they occur or are getting close to crossing over.
Thanks!

Comments

  • Assuming you want bullish crossovers, you would probably want to test first for the longer MA falling (MA today is less than the same MA some time ago). Then you would test for the shorter MA as less than the longer MA, but greater than some very large percentage of the longer MA,

    and [sma(10,close) < sma(50, close)]
    and [sma(10, close > sma(50, close) *.98]

    You would have to mess around with the .98 to see what works - maybe it should be .99, maybe .95, or something else.

    If you mean a price crossover, just substitute "close" for sma(10, close).
  • I'll grind on it and report back. Thank you Markd!
  • BB311BB311
    edited May 2021
    Trying to catch the 4hr 12EMA Crossover with the 26 EMA
    There is a sweet spot I like to monitor when the 4hr 12 EMA crosses over the 26 EMA. Finding it difficult to peg this crossover since its not a daily chart. Not sure if this is the right direction but I was trying to figure a way to find the 'Near cross on the daily that would suffice.

    Attached above is the view of the 4hr period, where the 12 crosses over 26. Also attached is the daily period chart showing the area of interest. Trying to catch the 4hr 12EMA Crossover with the 26 EMA

    Thanks!
    BB311
  • BB311BB311
    edited May 2021
    Your suggestion of,
    and [sma(10,close) < sma(50, close)]
    and [sma(10, close > sma(50, close) *.98]
    Looks promising. Thank you!
  • lmkwinlmkwin ✭✭
    try the 5/12 on the daily and see if that suffices. They appear to "line up"

    You can check your results pretty easily by setting up custom GalleryView charts. Set your GalleryIntraday to 4 hour and 12/26 EMA's. Set your GalleryDaily to 1 day and 5/12. Might be easier to see if you use the MACD Histogram with the parameters of 12,26 and 5,12 on the respective charts.

    For the "near cross" I suggest just shortening the shorter parameter. If the 4,12 has crossed the 5,12 should be close if not there yet, or not too far behind.

    As you know, no scanning on intraday periods is supported at the moment.

    When you run a scan, the results show with Icons that link to various chartstyles. The GalleryView is 4th from the left.

  • Okay. I'll chk it out. So far this is what I have built

    [ [exchange is NYSE] or [exchange is NASD] ]
    and [RSI(14) > 50.0]
    and [Volume > 999,999]
    and [ema(12,close) < ema(26, close)]
    and [ema(12, close) > ema(26, close) * .98]
    and [ROC(6) > 0.0]
    and [ROC(12) > 0.0]
    and [MACD Hist(12,26,9) > 0.0]
    rank by ROC(10)

    I ran the scan using your suggestions 4/12 buy replacing

    and [ema(12,close) < ema(26, close)]
    and [ema(12, close) > ema(26, close) * .98]

    with

    and [ema(4,close) < ema(12, close)]
    and [ema(4, close) > ema(12, close) * .98]

    It thinned the scan results down from 26 to 4

    I am new to this so forgive me for my ignorance. But what is the purpose of the "* .98" for the logic?
    "[ema(12, close) > ema(26, close) * .98]"
  • lmkwinlmkwin ✭✭
    the logic is that if The shorter MA is less than the longer MA but when you take the value of the longer MA and reduce it by multiplying by 0.98 or down 2%, AND the shorter ave is greater than that, it will be "close" to the longer MA.

  • Got it. Thanks! How do you write a simple qualifier where Price is greater that the 20 day sma?
  • Would this work?
    "and [close x sma(20, close)]"
  • markdmarkd mod
    edited May 2021
    The "x" operator means "crosses above" - which means yesterday, the close was below yesterday's sma 20, today, the close is above today's sma 20.

    For a simple "greater than" - meaning price is above the sma today, whether for the first time or for any number bars, use ">"

    and [close > sma(20, close)]
  • markdmarkd mod
    edited May 2021
    "But what is the purpose of the "* .98" for the logic?"

    Your original question was how to find stocks where price (or sma) was "close" to a longer sma.

    The scan engine doesn't understand "close" (meaning "near"). You have to be specific what you mean by "close" in terms the scan engine can understand.

    So you could specify some absolute distance, like say 2 points:

    and [close < sma(20, close)]
    and [close > sma(20, close) -2]

    For a 60 dollar stock or a 200 dollar stock that might really be close. But for a 5 or 10 dollar stock it could be pretty far away.

    A way around using an absolute distance would be to use a "relative" distance - like a percentage. Percentages can be expressed as decimals - so 50% is .50, 73% is .73, 1.0 is 100%, 1.2 is 120%, etc. So, if price is 50% of the sma (say price is 30 and the sma is 60), you can express
    that as "close = sma(20, close) * .5".

    But you want price and sma close together - in other words, almost equal. In decimals, equal would be 1.0 or 100%. A little less than equal could be .99, .98, .97, etc.

  • Thank you Markd! Clear as a bell.
  • Thanks to all.. Making this learning experience great.

    Another question if I may.
    What if I wanted to do the the exact opposite. of this...
    //and [ema(12,close) < ema(26, close)]
    //and [ema(12, close) > ema(26, close) * .98]

    Where I wanted to see the 12ema about to cross below the 26 ema. I tried flipping the operators around but no luck... I'm missing something...
    and [ema(12,close) > ema(26, close)]
    and [ema(12, close) < ema(26, close) * .98]

    Shout out to markd & lmkwin for the info!
  • and [ema(12,close) > ema(26, close)]
    and [ema(12, close) > ema(26, close) * .99]

    I think this might work...
  • markdmarkd mod
    edited May 2021
    Above means greater than (the 12 is above the 26), so you would use a decimal slightly greater than 1.0 (equal), maybe 1.01, 1.02 etc. to describe where the 12 is versus the 26.
  • Great! Thank you!
Sign In or Register to comment.