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
  • Scanning for Highs
  • A Note on Date Ranges
  • Scanning for Lows
  • Scanning for Divergences
  • Scanning for Consolidation
  • Conclusions

Was this helpful?

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

Writing Min/Max Scans

PreviousScanning for an Overlay of an IndicatorNextWriting Percent Change Scans

Last updated 12 months ago

Was this helpful?

The Min() and Max() functions are some of the more powerful scanning functions available at StockCharts, allowing you to compare a value to its range of values over a set period of time. Below, we outline four useful techniques for scanning with these functions.

Scanning for Highs

The Max() function is commonly used to scan for highs; in fact, it is used in our “New 52-week High” predefined scan. To view the syntax for this predefined scan clause, go to the Advanced Scan Workbench. From the Predefined Scans dropdown menu, choose “New 52-week High” and click “Add” to insert the clause into the Scan Criteria box.

By default, the scan clause looks like this:

[today's high > yesterday's daily max(253,high)]

The scan requires today's high to be greater than the maximum high observed anywhere over the previous 253 days (a calendar year has approximately 253 trading days).

In graphical form, the scan looks something like this:

The chart shows 1 year of data for 3M Co. (MMM). The red dashed line shows the highest closing value for the previous 253 days. Notice that only the most recent candlestick goes above this line - that is the new 52-week high.

If we wanted a new high “Close” instead of just the “High” (which could be an intraday high), there is no predefined scan for this, but we can easily modify the example above. Just replace today's “high” with “close” and replace the max “high” with “close” as below.

[today's close > yesterday's daily max(253,close)]

A Note on Date Ranges

You may have noticed that the scan clauses above specify that today's value must be greater than the previous 253 days' values, starting with yesterday's value. It's important that today's value is excluded from the Max() function. Let's take a quick look at the reason for this. Suppose our clause was:

[today's high > today's daily max(253,high)]

Imagine a stock that is hitting a new 52-week high of $100, right now. In that case, “today's high” equals 100 and “max(253,high)” also equals 100 (since today's high is included in that Max() function). Substituting those values into the scan criteria, we're left with “100 > 100” which will always be false. We will get zero results every time we run this scan.

For this reason, you must be sure to define your range for the Max() and Min() functions carefully, making sure that the value you're checking is not included in the range. If you were checking to see if yesterday's value was a new 52-week high, you'd want to use something like this:

[yesterday's high > 2 days ago daily max(253,high)]

This way, the value you're checking (yesterday's high), is excluded from the range used in the Max() function.

Scanning for Lows

The Min() function works the same way as the Max() function but looks for the lowest value in a range rather than the highest. Scanning for new 52-week lows looks very similar to the scan clause for new 52-week highs:

[today's low < yesterday's daily min(253,low)]

While the Min() and Max() functions are frequently used to check for price highs and lows, these functions can be used to check for highs and lows of any values. The following example checks whether the Chaikin Money Flow indicator value is the lowest it's been in the previous 10 trading days:

[CMF(20) < yesterday's min(10,CMF(20))]

Notice that we are using “yesterday” with the Min() function, just like we did with our Max() function, so that the value we are checking is not included in the range.

Scanning for Divergences

We can put our previous two examples together to scan for stocks that might have a negative divergence:

[today's high > yesterday's daily max(10,high)]
and [CMF(20) < yesterday's min(10,CMF(20))]

This example looks for securities that are currently having a 10-day high in price, but have the lowest Chaikin Money Flow value they've had in the past 10 days. This scan would produce a list of stocks that have a high potential for a negative divergence (the indicator is low while the price is high).

That list could be saved in a ChartList and then viewed in CandleGlance mode, allowing you to easily spot which stocks were actually having a negative divergence.

Scanning for Consolidation

Min() and Max() can be used together with arithmetic functions to scan for stocks that are in a narrow trading range. While these stocks are consolidating, they will not vary much above or below their moving average each day.

Let's say we want to find stocks that have been trading within 1% of their simple moving average over the last 10 days - a very tight consolidation range. To scan for this, we need to add two clauses:

  • The first clause should check that the highest value over the last 10 days is less than 1% over the 10-day SMA.

  • The second clause should check that the lowest value over the last 10 days is no more than 1% below the 10-day SMA.

[max(10,close) < SMA(10,close)*1.01]
and [min(10,close) > SMA(10,close)*0.99]

This criteria will find stocks with charts like the following:

This chart uses the Dots chart type to display the closing prices for each day. The moving average envelopes are showing 1% above and below the moving average. You can see that over the previous 10 days, the dots all fall within those envelope lines.

Conclusions

While the Max() and Min() scanning functions are traditionally used to find new price highs and lows, they can be used to scan for highs and lows of almost anything. Put together in a single scan, they can be used to search for possible divergences or to find values that fall inside or outside of a range.