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
          • Using the ChartList Summary
          • Using the ChartList Library
          • 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
  • Using OR Clauses
  • Using the Starting Date Adjuster
  • The Bottom Line

Was this helpful?

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

Scanning Over a Range of Dates

Scan Engines are designed to find charts with a specific set of technical criteria on a specific date. Occasionally, we get a question from someone trying to use the scan engine to find stocks with a specific set of technical criteria over a range of dates. We call this the “within” problem since they are looking for something that happened “within” a certain time period (e.g. “Show me all the stocks that had a MACD crossover within the past month.“).

Our scan engine doesn't support these “within” scans; frankly, they're not that useful in a real-world trading environment. From a high-level perspective, the purpose of scanning is to help you decide which stocks to buy or sell “soon” - that is, before the data used in the scan changes significantly. The standard scenario is to run your scans after the market closes in preparation for placing orders early the next day.

If you were to scan for stocks that had a MACD crossover within the last month, some of the results from that “within” scan might still be valid today, but other results might not. A stock that had a MACD crossover three weeks ago would still appear in your scan results - even if it crossed back under the next day - because it had a MACD crossover “within the last month.” Even more frustrating, your scan does not tell you which stocks still meet the scan criteria and which do not.

If you're encountering this “within” problem in your scan, there are a couple of techniques you might use to work around it, depending on what you are trying to accomplish with your scan.

Using OR Clauses

If you want to scan “within” a very short time period for just one of the clauses in your scan, then the OR clause technique might be a suitable option for you.

For example, let's say you have a complicated scan like this:

[type = stock] AND [country = US] 
AND [SMA(60,Close) > 10] 
AND [SMA(20,Volume) > 100000] 
AND [Close > SMA(50,Close)]
AND [ADX Line(14) > 20] 
AND [Plus DI(14) x Minus DI(14)] 

The first five lines define the universe of stocks you are interested in and the technical conditions that should be present for any scan results. The last line defines the signal - the event that happens today that makes you interested in this stock right now.

As an example, let's say you're interested in stocks where Plus DI crossed over Minus DI at any point in the last three days. To accomplish this, you can replace the last clause with this more complex one:

AND [ 
[Plus DI(14) x Minus DI(14)] 
OR [yesterday's Plus DI(14) x yesterday's Minus DI(14)] 
OR [2 days ago Plus DI(14) x 2 days ago Minus DI(14)]
]

This will scan for stocks that meet all your other technical conditions today and that had the crossover signal either today, yesterday or the day before yesterday. This can be useful for signals that might take a day or two to be confirmed by other indicators.

This OR Clause technique is a viable option for simple signals and short timeframes. However, once you try to scan for more than one signal and/or scan “within” a longer period, you will find the scan syntax quickly becomes unmanageable.

Using the Starting Date Adjuster

While the OR clause technique just focuses on a single clause, there may be situations where you want to check if all the clauses in your scan are true at the same time. If you want to scan for a stock that meets multiple criteria all on the same day, then the Starting Date Adjuster technique is recommended. This technique can be very useful for backtesting, but is generally not used when scanning for securities to invest in.

To use this technique, first change your “within” scan so that it refers to “today” instead. For example, let's take our original “Show me all the stocks that had a MACD crossover within the past month” scan and turn it into “Show me all the stocks that had a MACD crossover today.” You can then run the scan one time for each day in your “within” time period, changing the value of the Starting Date Adjuster on the Advanced Scan Workbench for each run.

When you use the Starting Date Adjuster to run your scan, it pretends that it is running the scan on the day you specified, scanning for stocks that met all your scan criteria on that particular day. If your scan has more to it than the MACD crossover clause, the scan will check whether or not all those other criteria were also true on the day you specified in the Starting Date Adjuster.

While it can be time-consuming to run all those separate scans for a large “within” period, one advantage is that you can easily see which stocks met the criteria on which days.

The Bottom Line

Scanning across a range of dates can be tricky to do, and isn't always very useful for real-world trading. Since you will be buying and selling the securities right now, it's best to focus on what those securities are doing right now, rather than what they did days or weeks ago.

However, scanning across a few days using OR clauses can be helpful in certain circumstances. The goal is to keep things simple, focusing on a very small date range and a single scan clause.

If you're scanning multiple criteria across a range of dates for backtesting purposes, the Starting Date Adjuster is the best approach. This will run your scan as though it was run on that day in the past, confirming whether all of your scanning criteria were true on that date.

PreviousWriting Percent Change ScansNextWriting Scans With OR Clauses

Last updated 1 year ago

Was this helpful?

Learn More.

Learn More.

OR Clauses
Starting Date Adjuster