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 Create a Scan

Hi everybody,

I'm trying to create a simple Scan. The 21-day moving average was greater than 5% BELOW the 50 day moving average four weeks ago, and, It is Less than 3% Away from it, Today.

Who can write this scan?
*(Would be Ever Better if the four weeks ago part can look for any day of that WEEK and same for the Today part, if anyone is that Skilled.)
my Hope is to make this 'Absolute value'? i.e. I can "flip it, and apply it to bullish scenarios...

Comments

  • Well, I think you need to think this out in a little bit more detail.

    When you say "greater than 5% below the 50 day moving average", can the 21 MA be ABOVE the 50 MA? Above the 50 is also greater than 5% below. Or do you want it between (less than) the MA and 5% less than the MA?

    "less than 3 per cent away today" - same thing - does that mean 3% below the 50 MA or 3% above the 50 MA, or either, or just below?

    Also, when you say four weeks ago, do you mean 20 trading days ago (four weeks x 5 trading days) ?

    As far as looking for "any day that week" - you wouldn't really want to code that, since the number of trading days ago for each day in that week would vary depending on the day of the current week that you run the scan. Better to write the scan for one day in the past, then use the scan start date to get results for other days.
  • Hi markd, Thanks. For *Both*, it must be greater than that number BELOW, but Never Above. (Price itself is not a consideration i should mention).
  • In AMZN stock, for example, the 21 day M.A. was 5% or more below the 50 m.a. (i believe) in early-to-mid February of this year... it was Less than 3% below, in early-to-mid March.

    Same, it was greatly-Below in mid-to-Late May... then less percentage Below in mid-June.
  • Basically, I want to see them Coming together. The intent is for at least the 50 day to ALWAYS be negative (Sloping down) and for the 21 day - it does Not matter - it can be sloping either up-or-down (probably will be sloping down, but doesn't matter.)
  • OK. So, MA 50 falling (less than x days ago), and 20 days ago, MA 21 below MA 50 by at least 5% 20, and today MA 21 below MA 50 by less than 3%.

    [group is sp500] // or whatever you want

    // MA 50 falling 20 days ago
    and [20 days ago sma(50, close) < 30 days ago sma(50, close)]

    // 20 days ago, MA 21 more than 5% below MA 50
    and [20 days ago sma(21, close) < 20 days ago sma(50,close) * .95]

    // MA 50 still falling today
    and [sma(50,close) < 10 days ago sma(50, close)]

    // today, MA 21 below MA 50
    and [sma(21,close) < sma(50,close)]

    // today, MA 21 above 3% below MA 50
    and [sma(21, close) > sma(50,close) * .97]
  • Thank you Sooo much! This is Pretty much 'exactly' what i was Looking for!

    One last tweak: Is there any way of saying the 21 day MA can be Either WITHIN 3% Above the 50 day MA -Or- WITHIN 3% Below the 50 day? Like +/- of up to 3%, in each direction?
  • On the most recent Trading Day.
  • I thought you might get to that.

    // today, MA 21 above 3% below MA 50 or less than 3% above

    // begin "or" statement
    and [

    [sma(21, close) > sma(50,close) * .97]

    or

    sma(21,close) < sma(50,close) * 1.03]

    ]
    // end "or" statement


  • lmkwinlmkwin ✭✭
    If interested in using EMA's, the PPO could be a decent option for scan and display. The 1st 2 PPO parameter values are set for the EMA's and they display the percent value difference between the two. PPO(21,50,0) will show as a histogram. 21,50,1 as a line. You can customize the display and set Horizontal Line overlay on the PPO at the values of interest





  • lmkwinlmkwin ✭✭
    2 new filters were recently added to the Technical Indicators in the Scan Workbench.

    Distance from a moving average.

    Default for filters:

    and [DistFromSMA(200) > 0]
    and [DistFromEMA(200) > 0]

    A positive distance is ABOVE the trendline requested. A negative distance is BELOW the trendline.

    You can modify the value of the period and the distance. You can use the indicator in a Rank By as well. Rank By [DistFromSMA(200)]

    You can also add modifiers to it [DistFromSMA(200,low) < 0] for example

    I've only played a little with this one so don't have a feel for how adding a more complex modifiers actually work or not. But it is a new feature added to the Workbench. They also added the values for several fixed SMA's into the Summary view available columns.

  • Holy Chap, That is AWESOME!!
  • Thanks Guys!!
  • I've been wrestling with this for Months, If Not years.... probably before I even discovered Stockcharts.com

    Going to take me a Little while to Digest this, and apply some various variations

    I am almost certain that I will use your last post, markd, and apply it to Other indicators.

    At any rate, thank you Both, so much!!! What a great Timesaver!
  • Huge help, both of you...!! #Stoked. Amp'd
  • lmkwinlmkwin ✭✭
    This is the SharpChart setting on that PPO for AMZN I displayed if interested



Sign In or Register to comment.