Scanner to Look for stocks that have gapped above or below 200MA (and ideally 200MA is flat)?

JoeSD

Member
I've looked and can find nothing... I d/n code so hoping someone has done this or it can be done. Thanks. Joe
 
Solution
Try this. The gap part is easy, and can be easily modified. The moving average being flat is more tricky, its relative and arbitrary. In this, its using a sample of the average's slope as a percentage of the average itself. There are other ways to go about this as well.

Code:
Input Bias = {default bull, bear};
Input Slope = .25;
plot Scan;
def SMA =
    simpleMovingAvg(close,200)
;
def Slp =
    (Absvalue(SMA - SMA[3]) / sma[3]) * 100 < Slope;
;
Switch (Bias) {
    Case Bull:
        Scan = High[1] < SMA
        and low > SMA
        and Slp
        ;   
    Case Bear:
        Scan = Low[1] > SMA
        and High < SMA
        and Slp
        ;
    ;   
}
Scan.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
twDHeKJ.png
Try this. The gap part is easy, and can be easily modified. The moving average being flat is more tricky, its relative and arbitrary. In this, its using a sample of the average's slope as a percentage of the average itself. There are other ways to go about this as well.

Code:
Input Bias = {default bull, bear};
Input Slope = .25;
plot Scan;
def SMA =
    simpleMovingAvg(close,200)
;
def Slp =
    (Absvalue(SMA - SMA[3]) / sma[3]) * 100 < Slope;
;
Switch (Bias) {
    Case Bull:
        Scan = High[1] < SMA
        and low > SMA
        and Slp
        ;   
    Case Bear:
        Scan = Low[1] > SMA
        and High < SMA
        and Slp
        ;
    ;   
}
Scan.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
twDHeKJ.png
 
Solution
Try this. The gap part is easy, and can be easily modified. The moving average being flat is more tricky, its relative and arbitrary. In this, its using a sample of the average's slope as a percentage of the average itself. There are other ways to go about this as well.

Code:
Input Bias = {default bull, bear};
Input Slope = .25;
plot Scan;
def SMA =
    simpleMovingAvg(close,200)
;
def Slp =
    (Absvalue(SMA - SMA[3]) / sma[3]) * 100 < Slope;
;
Switch (Bias) {
    Case Bull:
        Scan = High[1] < SMA
        and low > SMA
        and Slp
        ;  
    Case Bear:
        Scan = Low[1] > SMA
        and High < SMA
        and Slp
        ;
    ;  
}
Scan.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
twDHeKJ.png
Joshua,

thank you so much and I will give it a shot. Much appreciated. Joe
 
Try this. The gap part is easy, and can be easily modified. The moving average being flat is more tricky, its relative and arbitrary. In this, its using a sample of the average's slope as a percentage of the average itself. There are other ways to go about this as well.

Code:
Input Bias = {default bull, bear};
Input Slope = .25;
plot Scan;
def SMA =
    simpleMovingAvg(close,200)
;
def Slp =
    (Absvalue(SMA - SMA[3]) / sma[3]) * 100 < Slope;
;
Switch (Bias) {
    Case Bull:
        Scan = High[1] < SMA
        and low > SMA
        and Slp
        ;  
    Case Bear:
        Scan = Low[1] > SMA
        and High < SMA
        and Slp
        ;
    ;  
}
Scan.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
twDHeKJ.png
Joshua,

Can this be turned into a scan that I can put on a watchlist? Tied to watch YouTube videos how to do this but since it is a study I was not sure how to do it. Thanks. Joe
 
Joshua,

took a shot at it and set it on the daily within 2 bars (bull) and ran the scan and here is what the results showed (I named it "Scan_for_Gappers)200SMA"-

/Users/josephlavelle/Pictures/Snagit/Autosaved Captures.localized/2022-04-02_10-31-07.snagproj


Don't know if you will be able to see the link...? I tried for 20 minutes to figure out how to just insert a screenshot of the scan results into the message and this was the best I could figure out. :)

Thanks again so much. This is really confusing for me.


Joe
 
Get a little program called "green shot" its free.

You can just drag an area with your mouse.

There is an options to auto-upload to imgur, and it copies the link to your clipboard.

You can post a screen cap in like 2 seconds.

4ynYq3X.png
 
Thanks, I tried with both Snagit, and apple screenshots but this message system in here (usethinkscript) wouldn't let me post either. I will try greenshot and see if that works. Joe
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
425 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top