LogoLogo
Return to StockChartsCharts & ToolsArticlesChartSchoolYour Dashboard
  • Support Center
  • Finding Your Way Around
    • Intro to StockCharts
    • Navigating the Website
    • Logging In for the First Time
    • Members Dashboard
  • data and ticker symbols
    • Data Availability
      • Markets We Cover
      • Real-Time Data
        • BATS Real-Time Data
      • Extended Hours Data
      • Data Bar Periods
      • Price Data Adjustments
      • Historical Data
        • How Do I Download Data to Excel?
        • StockCharts Historical Sector Data
    • Ticker Symbols
      • Ticker Symbol Conventions
      • How to Find a Ticker Symbol
      • Using the Index Catalog
      • Ratio and Difference Symbols
      • Pseudo-Symbols
      • User-Defined Indexes
  • Charts & Tools
    • SharpCharts
      • SharpCharts Workbench
        • Creating and Viewing SharpCharts
        • Printing and Sharing SharpCharts
        • Editing SharpCharts
          • Using the SharpCharts Interactive Date Slider
          • Charting Market Breadth Indicators
          • SharpCharts Parameter Reference
        • Saving SharpCharts
        • Additional SharpCharts Workbench Tools
          • Viewing ChartLists on the SharpCharts Workbench
          • Viewing Alerts on the SharpCharts Workbench
          • Viewing Options Data on the SharpCharts Workbench
      • ChartStyles & StyleButtons
        • Working with ChartStyles and StyleButtons
        • Using the ChartStyle Library
        • Tool-Specific ChartStyles
      • ChartNotes
        • Annotating SharpCharts with ChartNotes
        • ChartNotes Annotation Tool Reference
          • Line Tools
          • Text Annotation Tools
          • Shape Tools
          • Line Study Tools
      • ChartLists
        • Summary View
        • ChartList View
        • ChartBook View
        • Performance View
        • Correlation View
        • Edit View
        • ChartList Reports
        • ChartPacks
      • Classic SharpCharts Workbench
      • StockCharts Mobile App
    • StockChartsACP
      • Creating ACP Charts
      • Multi-Chart Layouts in StockChartsACP
      • Viewing ACP Charts
      • Printing and Sharing ACP Charts
      • Editing ACP Charts
      • Applying Chart Templates to ACP Charts
      • Annotating ACP Charts
        • StockChartsACP Line Tools
        • StockChartsACP Text Annotation Tools
        • StockChartACP Shape Tools
        • StockChartsACP Line Study Tools
      • Working with Saved ACP Charts
      • StockChartsACP Plug-Ins
        • Chaikin Power Gauge Plug-In
        • GoNoGo Charts Plug-In
        • Larry Williams Stock Trading Starter Pack Plug-In
        • MarketGauge Plug-Ins
        • Simpler Trading Moxie Indicator Plug-In
        • Trading Simplified by Dave Landry
        • Trend Investor Pro Indicator Edge
    • Other Charting Tools
      • P&F Charts
      • GalleryView
      • Seasonality Charts
      • CandleGlance Charts
      • MarketCarpets
      • Interactive PerfCharts
      • RRG Charts
      • Dynamic Yield Curve
    • Research Tools
      • Symbol Summary
      • Options Summary
        • OptionsPlay Explorer
      • OptionsPlay Strategy Center
      • Market Summary
      • Sector Summary
      • Industry Summary
      • Index Members
      • StockCharts Technical Rank (SCTR) Reports
      • Earnings Calendar
      • Cryptocurrency Summary
    • Reports and Galleries
      • The Ticker Cloud
      • Historical Chart Gallery
      • Predefined Scan Results
        • Customizing Predefined Scans
      • Predefined Technical Alerts
      • DecisionPoint Chart Gallery
      • Public ChartLists
        • Becoming a Public ChartList Author
      • SharpCharts Voyeur
  • Scanning & Alerts
    • Technical Scans
      • Scanning for Stocks: The Basics
      • Advanced Scan Workbench
      • Standard Scan Workbench
      • Working With Scan Results
    • Scan Writing Resource Center
      • Planning Scans
      • Writing Scans
      • Scanning Tutorials
        • Scan Workbench Tutorial
        • Scan Results Tutorial 1
        • Scan Results Tutorial 2
        • Writing Scans Tutorial 1
        • Writing Scans Tutorial 2
        • Creating Scan Templates Tutorial
        • Troubleshooting Scans Tutorial 1
        • Troubleshooting Scans Tutorial 2
        • Troubleshooting Scans Tutorial 3
      • Scanning Case Studies
        • Scanning for Crossovers
        • Scanning for "Near Crosses"
        • Scanning for Divergences
        • Scanning for Relative Strength
        • Scanning for Consolidation and Breakouts
        • Scanning for Selling Climaxes
        • Scanning for SCTRs
        • Scanning Ichimoku Clouds
        • Scanning for P&F Chart Patterns
        • Scanning Your ChartLists
        • Scanning for an Overlay of an Indicator
        • Writing Min/Max Scans
        • Writing Percent Change Scans
        • Scanning Over a Range of Dates
        • Writing Scans With OR Clauses
      • Troubleshooting Scans
        • Troubleshooting Equality Scans
      • Getting Help With Scans
      • Scan Syntax Reference
        • Scan Syntax: Ticker Properties
        • Scan Syntax: Price, Volume, and SCTRs
        • Scan Syntax: Technical Indicators
        • Scan Syntax: Technical Functions
        • Scan Syntax: Predefined Patterns
        • Scan Syntax: Groups
      • Advanced Scan Library
        • Sample Scans
        • Predefined Scans
        • Published Scans
        • User-Contributed Scans
        • Gord Greer's Scan Building Blocks
    • Technical Alerts
      • Technical Alert Workbench
      • Your Alerts
  • Your Account
    • Subscribing to StockCharts
    • Service Levels & Data Plans
    • Login & Passwords
    • Your Account Settings
    • Managing Your Subscription
      • Cancelling Your Account
    • StockCharts Add-Ons
      • OptionsPlay Add-On
  • Learning More
    • Market Commentary
      • Blogs
      • ChartWatchers Newsletter
      • StockCharts TV
    • Educational Resources
    • Frequently Asked Questions (FAQs)
    • Step-By-Step Instructions
      • SharpCharts How-Tos
        • SharpCharts Workbench How-Tos
          • How to Print a SharpChart
          • How to Share a SharpChart on Social Media
          • How to Email a SharpChart
          • How to Insert a SharpChart in a Document or Presentation
          • How to View Indicator and Overlay Values for Specific Days
          • How to Save a SharpChart
        • SharpChart Editing How-Tos
          • How To Use The Interactive Date Slider
          • How to Display More than One Symbol on a SharpChart
          • How to Create Overlaid Charts
          • How to Add an Overlay to an Indicator
          • How to Add a Moving Average to the Volume Bars on a Chart
        • ChartNotes How-Tos
          • How to Pin an Annotation on a SharpChart
          • How to Save a Chart from a Blog Article with the Author's Annotations
        • ChartList How-Tos
          • How to Use the ChartList Summary
          • How to Search for a Saved Chart in Your ChartLists
          • How to Share a ChartList with Another Member
        • ChartList Editing How-Tos
          • How to Create a New ChartList
          • How to Add Predefined Symbol Groups to a New ChartList
          • How to Add Predefined Groups into an Existing ChartList
          • How to Upload Symbols to a ChartList from a Spreadsheet
          • How to Rearrange Charts in a ChartList
          • How to Delete a Saved Chart from a ChartList
      • StockChartsACP How-Tos
        • Setting Period, Type And, Range
        • Chart Attributes
          • Part One
          • Part Two
        • Sharing And Printing
        • Saving Charts
          • Saving A New Chart
          • Saving An Existing Chart As New
        • Chart Templates
          • Applying Predefined Chart Templates
          • Saving A New Chart Template
        • Using ChartLists
          • Creating A New ChartList
        • Chart Layouts
          • Accessing Chart Layouts
          • Creating A New Custom Layout
        • Additional Tools
          • Accessing Research Tools
    • Troubleshooting
      • Unable to Log In
      • Website Slow or Down
        • Using OpenDNS
      • Website Functionality Issues
    • Customer Support
    • Policies & Limitations
      • Terms of Service
      • Privacy Statement
      • No Service Level Guarantees
      • Data Policies
      • Usage Limitations
      • Reprint Permission Policies
      • Billing Policies
      • Membership Policies
      • Public ChartList Policies
      • Customer Support Policies
Powered by GitBook
LogoLogo

ON STOCKCHARTS

  • Charts & Tools
  • Articles
  • StockCharts TV
  • ChartSchool

MEMBERS

  • Your Dashboard
  • Your ChartLists
  • Advanced Scans
  • Technical Alerts

HELP

  • Support Center
  • FAQs
  • Contact Us
  • Pricing

COMPANY

  • About Us
  • What's New
  • Careers
  • StockCharts Store

© StockCharts.com, Inc. All Rights Reserved.

On this page
  • Running the Default Scan
  • Adding Clauses to Define the Scan Universe
  • Adding Clauses to Scan for Technical Conditions
  • Adding a RANK BY Clause
  • Saving Your Scan
  • Learn More

Was this helpful?

Export as PDF
  1. Scanning & Alerts
  2. Scan Writing Resource Center
  3. Scanning Tutorials

Writing Scans Tutorial 1

PreviousScan Results Tutorial 2NextWriting Scans Tutorial 2

Last updated 1 year ago

Was this helpful?

This tutorial will walk you step-by-step through writing a simple scan to run from the Advanced Scan Workbench. Our scanning tutorials assume only a basic knowledge of common technical indicators and chart patterns. This tutorial may build on skills learned in prior scanning tutorials (links are provided where appropriate).

By the end of this tutorial, you will be able to write a simple scan that searches for US stocks with a certain RSI value and, subsequently, rank your results from highest to lowest RSI values. Once you've mastered these skills, you should be sure to check out the to learn about and practice other aspects of scanning.

Here's a Tip: Open this page in another tab (or print it) so you can refer to it as you follow along.

Running the Default Scan

Step 1:

Open the Advanced Scan Workbench. When you first open the workbench, the following scan clauses will already have been added to your Scan Editor Box:

[type is stock] and [sma(20,volume) > 40000]

This scan looks for stocks that have averaged at least 40,000 shares of volume per day over the last 20 trading days. Let's break it down a little further.

There are two scan clauses in this scan:

  • [type is stock]

  • [sma(20,volume) > 40000]

Each scan clause must be enclosed in square brackets. A scan clause contains a simple true/false test to check against each symbol in the database. The first clause above simply checks to see if the symbol is a stock (as opposed to a mutual fund, index, etc.). If the symbol is a stock, then the clause is true; if not, the clause is false and the symbol will not appear in the scan results.

If you have multiple clauses in your scan, they must be joined together by putting “AND” or “OR” between the clauses. If you use “AND” to join them, that means both clauses must be true. If you use “OR” instead, only one of the clauses needs to be true. “OR” clauses can be especially tricky, so we will stick with “AND” clauses in this tutorial. To learn more about using “OR” clauses, please see our .

Step 2: Run this default scan in the Advanced Scan Workbench.

If you are not familiar with the process for running a scan in the Advanced Scan Workbench, we recommend accessing our , which will help you build and run the scan listed above.

Step 3: A new browser window (or a new tab in your current browser window) should appear with a results page that looks like the one below.

Notice that there are 999 results. This is the maximum number of results that you can get for your scan. In reality, there are thousands of stocks in our database that average at least 40,000 shares a day in volume. To narrow our focus, we'll need to add more clauses to our scan, which will give us a smaller set of relevant stocks in our scan results.

Note: When this tutorial was created, members were limited to 999 scan results; that limit is now 2000 results.

Adding Clauses to Define the Scan Universe

A quick way to narrow down the scan results is to add clauses that define the universe of symbols that you might invest in. Only interested in mutual funds? Indian stocks? Stocks traded on the Toronto Stock Exchange? S&P 500 stocks? Clauses can be added to limit your scan results to any of these requirements. For this tutorial, let's limit our results to US stocks.

Step 4: Click in the Scan Editor Box and add the following text:

AND [country is US]

Note: You can also achieve the same effect by choosing “country” from the “Ticker Properties” menu in the Scan Components area of the workbench and click the “Add” button. This inserts a sample scan clause for limiting results to a specific country.

Step 5: Click the “Check Syntax” button to make sure your scan clauses have been typed in correctly. This step is recommended after each clause you add. It is much easier to find a typo in one clause than in twenty clauses, so it's best to check your syntax regularly.

Another way to limit the universe of stocks is through simple price and volume tests. In this case, let's limit our universe to symbols where the current closing price is at least $80.

Step 6: Choose “Close” from the “Price, Volume & SCTRs” menu in the Scan Components area and click the “Add” button.

Step 7: Notice that the sample clause looks for symbols where the close is greater than 99.9. You can change this by typing in a different value in the Scan Editor Box. In this case, delete the “99.9” and replace it with “80” - your scan should now read like this:

[type is stock] and [sma(20,volume) > 40000]
and [country is US]
and [Close > 80]

Step 8: Click the “Check Syntax” button again to ensure all of the scan clauses are correct. Then, click “Run Scan” and check out the results.

The goal of defining the universe is to weed out large groups of symbols that you would never invest in anyway. The more of these you can exclude from your scan up front, the faster your scan will run against the remaining symbols. Many universe-defining sample clauses can be found in the Scan Components area, under the following menus:

  • Ticker Properties

  • Price, Volume & SCTRs

  • Indexes & ETFs

  • ChartLists

  • Sectors & Industries

Adding Clauses to Scan for Technical Conditions

Once you've defined your universe, you want to scan for symbols in your universe that are experiencing specific technical conditions and signals. Are you interested in stocks that are overbought or oversold? Stocks having a MACD Crossover? Stocks that have just had a dragonfly doji? Clauses can be added to limit your scan results based on technical indicators, candlestick patterns, P&F patterns and more. For this tutorial, we will limit our results to stocks with an RSI value above 70.

Step 9: Chose “RSI” from the “Technical Indicators” menu in the Scan Components area, area and click the “Add” button.

Now, your scan should read like this:

[type is stock] and [sma(20,volume) > 40000]
and [country is US]
and [Close > 80]
and [RSI(14) > 70.0]

Step 10: Click the “Check Syntax” button again to ensure all of the scan clauses are correct. Then, click “Run Scan” and check out the results.

Step 11: Try changing to a 5-period RSI by clicking in the Scan Editor Box, deleting the “14” and replacing it with a “5” instead. Now, that clause should read like this:

and [RSI(5) > 70.0]

Step 12: Click the “Check Syntax” button again, then click “Run Scan” and check out the results. Have the results changed from the 14-period RSI scan?

Many technical condition/signal sample clauses can be found in the Scan Components Area, under the following menus:

  • Technical Indicators

  • Candlestick Patterns

  • Candlestick Building Blocks

  • P&F Patterns

  • Predefined Scans

Adding a RANK BY Clause

Adding a special RANK BY clause allows you to view and sort your scan results by a value that is not normally included in the scan results table. This is commonly used to see the values for a technical indicator signal or condition without having to a launch a chart for each one. Let's add a rank by clause for RSI(5), the technical condition that we're scanning for in our current scan.

Step 13: Click in the Scan Editor Box. At the end of your scan, start a new line and type the following text:

RANK BY [RSI(5)]

Step 14: Click the “Check Syntax” button again, then click “Run Scan” and check out the results. Notice the new column at the right side of the scan results table, showing the RSI(5) value.

Saving Your Scan

When you're happy with your scan, you should save the scan syntax. This way, you can run it again at a later date without having to reenter all the clauses.

Step 15: On the Advanced Scan Workbench, click the “Save As” button above the Scan Editor Box.

Step 16: Choose a name for your saved scan, and click “OK”. In this tutorial, we will use “5-day RSI Scan” as the name for our saved scan.

Step 17: To load this saved scan and use it at a later date, simply select it from the “Your Saved Scans” menu above the Scan Editor Box.

Learn More

Notice the number in parentheses after RSI. These parentheses are used to define certain parameters for technical indicators. In the case of RSI, there is one parameter that shows the number of periods to use in calculating the RSI value. By default, it is calculated with 14 periods, but you can change the number of periods by changing this parameter. Check out our for details on the parameters used for each technical indicator.

Now that you've mastered the basics of writing scans, check out our and learn more about how to create more complex scans.

For more in-depth information on writing scans, please check out our in the Support Center.

Scan Syntax Reference
second Writing Scans Tutorial
Writing Scans article
other scanning tutorials
tutorial on this topic
Support Center article on the topic