An easy way to find breakouts – UPDATED for 1.6

by Sep 18, 2020All Articles, Technical Analysis, Education

NOTE: The scripting formulas in this article has been updated from a previous version to reflect changes made in the PIVOT() function made in Optuma 1.6 to account for unconfirmed pivots. As such, if you have existing scans or formulas they should be amended after installing the 1.6 update, as per the examples below.

As you may know, Optuma has several tools to help identify significant turning points, such as the various swing overlays (including Gann, percent, and volatility swings) but one tool I’ve started to use more and more is the Pivot Label tool.

You can read more about the tool here, but basically it labels high and low turns based on the number of bars either side, so the higher the number the more significant the turn. In the example for the S&P500 below, the Pivot Labels on the left have been set to 10, which means that there must be at least 10 bars both before and after the high/low for a label to appear (in this case I used daily bars, but they work the same in any timeframe). Compare that to the 20 bar pivot on the right which will obviously show fewer – but more significant – turns as the interval required either side is higher.

Note: you can change the chart or scan timeframe to weekly to make the turns more significant.

In this article I want to show you how to create a scan to identify breakouts from previous pivot levels and save those results as a watchlist in a workbook, so that every time the workbook is opened the scan will be automatically executed and the list updated – a great timesaver!


Creating the scan using the Pivot Labels tool

If we know the last pivot value then we can create a scan to alert us when that level has been breached, thus signifying a potential breakout that might be a great trading opportunity. In the scripting language we can use the PIVOT() function to calculate these levels.

In the script editor window add the PIVOT() function and click on the text to select your parameters, eg 15 bar pivots based on highs:

This script on its own will simply return true when the current bar is the highest bar for at least 15 bars. To get the actual value at that point, we need to use the VALUEWHEN() function, ie the value when the pivot condition was true. By default the VALUEWHEN() function calculates the closing price of the trigger day, so we’ll need to nest High() in the parentheses to get the high price. The complete formula will be as follows (remember the lines beginning  // are comments):

In this example of $MSFT, the last 15 bar high pivot was at $232.86, as shown in the watchlist and plotted on the chart using the same formula above in a Show Plot tool.

So now we have the previous pivot value we can compare it to the current price, and set a true/false signal if that level has been taken out using CrossesAbove in the formula:

Here’s an example of the scan results, showing $MMM closing above June’s high of $169.54 (note that the scan would not have been triggered in early September as even though the highs were above previous pivot level they did not close above it).

The Days Since Pivot watchlist column formula tells you how long the pivot level has been in place using the TimeSinceSignal function (ie 70 days for $MMM, and 25 for $FMC):

The watchlist also has a % of 20D Avg Vol column to show the if there was strong volume associated with the breakout. In the case of $MMM the volume was near the average, but $MOS had over twice the 20 day average.

Breaking below pivot lows

To scan for breaking support the concept is exactly the same but with slightly different syntax for a pivot low because the price action is going in the opposite direction:


Important Note! Because of the way pivot labels are calculated it is not suitable for the PIVOT() function to be used in quantitative testing, as recent labels can move when new data is added to the chart.

Save time by opening scan results in a Watchlist or Page Layout

A great timesaver is to open scan results as a watchlist or previously saved Page Layout, and then saving that in a workbook. From the Scan Results window click Export Results > Open Results As:

Because the watchlist is linked to the scan, when you open the workbook tomorrow (once the end-of-day data has been downloaded) the list will automatically update with the new breakouts.

This means you can have a workbook containing a series of page tabs linked to scans, so as you click on the tab the stocks with a true result will populate the watchlist.


Automated scans and outputs

Enterprise Services clients can set up command line prompts in the Windows Task Scheduler, which will automatically run the scans at a time of your choosing. The results will be automatically exported as either images, a PDF, a .csv list of symbols, or even an email (Microsoft Outlook clients only) using your preferred page layouts. You can watch a video on building command lines here.


Need more help?

If you have any questions or need more help with creating custom scans or formulas please post on the scripting forum. Make sure you search the forum first to see if your question has already been answered, but if you need more advanced help then one-on-one consulting sessions are also available.

Share Link
Darren Hawkins, MSTA

Darren Hawkins, MSTA

Senior Software Specialist at Optuma

Darren is the senior Software Specialist at Optuma. He joined the company in 2009 after attending an introductory technical analysis course. Darren now instructs users all over the world, from experienced Wall Street traders and professional money managers to individual traders drawing their first trendlines.

Darren grew up in the UK and attended college in the USA where he earned a BA in Economics from St Mary's College of Maryland. He went on to spend a few years working at the Nasdaq Stock Market in Washington DC. Going on to live and work in Australia, the US and currently the UK, Darren has a broad understanding of the individual needs of traders, portfolio managers and investors utilising a wide range of methodologies.

In 2014 Darren passed the UK-based Society of Technical Analysts diploma course, and when not looking at charts he keeps a keen eye on England's cricket team - especially if they are playing against Australia. He lives in the Essex countryside in England, with wife Wendy and their labrador, Gabba.


Submit a Comment

Your email address will not be published. Required fields are marked *

Blog Signup

Pin It on Pinterest

Share This