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.

Lower EMA over higher EMA for past x days

I'm looking for a MA to be over another MA for a certain number of days. I've tried the following and it doesn't work as expected:

and [min (30, EMA(8)) > EMA (18) ]

It should say that EMA (8) has been over EMA (18) for the past 30 days. I've tried a look-back period of 20 days, and all I got were similar stocks that seemed to have been bought some weeks ago and displaying a straight line, e.g., before markets open (Aug.13): ALIM, SHCR, SILK, WKME.

I'm just looking for a lower EMA to have been above a higher EMA for a certain number of days, to display an upper trend. Normally, I should get many candidates, and I have other indicators to filter out the results (not shown here.)

Any ideas what I am doing wrong?
Thanks!

Comments

  • lmkwinlmkwin ✭✭
    So, MA1 has to be above MA2 for X periods.

    Put another way the MA1 maintains a positive percentage difference to MA2 for X amount of days

    If you are using Exponential MA's, it's pretty easy as you can use the PPO. PPO(MA1,MA2,1) greater than 0 will give you one day. Using the Min(30,PPO(MA1,MA2,1)) > 0 will give you 30 days of Positive difference. You can use a 0 instead of the 1 to show the PPO as a Histogram. The 1 just shows it as a line.

    Another way is to use the PctDiff function. It defaults in to the workbench like this:

    and [PctDiff(close,sma(50,close)) < 5]

    This is looking for the Percentage difference between the close and the SMA50 to be less than 5 percent. So anywhere between 4.99 and -99.99 would show up.

    You can change the close to be your MA1 and the 2nd variable to be your MA2. Then do your Min on the PctDiff to be > 0.

    PctDiff works on pretty much any variables in the scan workbench, not just MA's.

  • Those are great tips! The PPO is the easiest version to work with, however the PctDiff seems to give more scan possibilities.

    Thanks!
  • lmkwinlmkwin ✭✭
    edited August 14
    There is usually several ways to accomplish a task. Use the tools you are comfortable with.

    I mentioned the PPO because:

    1. You are using EMA's and PPO uses EMA's (MACD does also but I prefer PPO).
    2. You can actually view it on the chart. PctDiff isn't a charting option. I like things you can show on a chart to "verify" the scan results with.

    The reason that your original scan code wasn't producing the results that you hoped for is that

    and [min (30, EMA(8)) > EMA (18) ]

    is looking for the LOWEST value for the EMA8 in the last 30 days and that value has to be greater than the current EMA18. It should produce a bunch of sideways stocks, like the buyouts you mentioned.
  • markdmarkd mod
    edited August 14
    Just to clarify, for anyone new to PPO, in the scan you actually need to use PPO Hist -

    and [min(30, PPO Hist(8,18,0)) > 0]

    The editor will not allow just PPO in that line, so you have to choose between Line, Signal and Hist. You can see this in the Technical Indicator drop down under the scan window (always a good idea to use the drop downs, AND have the Advanced Editor (upper right corner of the scan window) turned on (check mark visible) ). On the chart, you choose just PPO.

    Pretty good method for picking out seriously trending stocks.
  • lmkwinlmkwin ✭✭
    The thing I like about PPO is the same thing I like about Stochastics. You can use them to, relatively quickly, segment security momentum and direction, like Weinstein Stages, if so inclined. It's nice to have an indicator as a guide.

    On an entirely unrelated note, I just found out recently on a Joe Rabil video comment section, about an undocumented StockCharts.com feature. Someone asked him about his ADX parameter.

    You can add an addition parameter to the ADX (with +DI and -DI). The ADX w DI's default into the chart with a parameter 14. The 14 is used to calculate the ADX as well as the +DI and -DI lines. You can add an additional parameter to be used to calculate the ADX with one parameter and the +DI and -DI with a different parameter.

    Joe Rabil uses 13,8 for his parameter. The 13 is use to calculate the DI's lines and the 8 is used to calculate the ADX line. I don't currently use ADX but I found it interesting that you can segment the calculations of the two differently. Might be worthy of review. I don't know about if you can scan like this and I probably won't be checking that out. Just passing the info along.
  • lmkwinlmkwin ✭✭
    An addition to the list of StockCharts.com things I didn't know, is an optional use of the $Symbol parameter.

    There are market breadth indicators that are associated with various indexes. Most common are the $SPX indicators. The $SPXA50R is the percent of SPX stocks above their 50 day moving average for example. There are many more $SPX indicators as well. There are similar symbols for the $Mid (SP Midcap 400) and the $Sml (SP SmallCap 600).

    Let's say you have a chartstyle set up for the index breadth indicators. You can move from one index to another by filling in the Symbol for the index and setting your breadth indicators with the following parameters, and the chart will update to the new index and indicators automatically.



    So you can put $SPX in the Symbol for the chart and it will add the indicators you requested for the $SPX. If you change to the $MID in the Symbol, the chart will update with the $Mid indicators you requested. Pretty nifty in my opinion.
  • Can you show specific examples of this .... like 1 example for each of the 4 stages would be ideal.

    The thing I like about PPO is the same thing I like about Stochastics. You can use them to, relatively quickly, segment security momentum and direction, like Weinstein Stages.
  • Thanks for asking @azb. At some point I may put something regarding PPO on the Weinstein Stage 1 discussion to keep that all together.
    https://scan.stockcharts.com/discussion/2772/weinstein-stage-1#latest

    If the objective is to determine a Stage, I'm partial to the Stochastic over the PPO as it uses the High/Low for the period and clearly shows where the important levels are in relation to the objective. The PPO uses EMA lines and their relationship to each other and a moving average of that and there is a bit more "interpretation" involved. The nice thing about the PPO is that it shows the differences as a percentage of the price, and you can put Horizontal Lines on it to show where the price is historically extended and due for a pullback.

    I'm a user of ThinkorSwim and I use ThinkScript to create or copy custom indicators for my charts there. There is one that was shared on the useThinkScript.com forum. It was created by TrendAdvisor that follows along with the stages.
    https://www.trendadvisor.com/diamond_analysis.html

    TrendAdvisor is no longer around but that website is still up and if you click on many of the links for some interesting information, including the founder and creator of the indicator's interview with Stocks & Commodities magazine where he details the whole thing.
Sign In or Register to comment.