An easy way to find breakouts

by Mar 29, 2019All Articles, Technical Analysis, Education

As you may know, Optuma has various tools to help identify significant turning points, such as the various swing overlays (including Gann, percent, or 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 oil below, the Pivot Labels on the left have been set to 10, which means that there must be at least a 10 bar interval before or after until another bar can cross the same high or low price (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 is higher.

And this is how they compare with a 3 bar Gann Swing overlay in determining the highs and low turns:

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 these support and resistance 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 $DIS, the last 15 bar high pivot was at $115.50 (which was in fact the highest high in 54 bars), as calculated in the watchlist.

Tip: use the above formula in a Show Plot tool to automatically draw the pivot values on the chart (shown in blue)

So now we have the previous pivot value we can compare it to the current price, including whether that level has been taken out using CrossesAbove in the formula:

Here’s an example of the scan results, showing $DRI finally breaking above November’s strong resistance when it failed several times to get above $114.46.

The Days Since Pivot watchlist column formula tells you how long the pivot level has been in place using the TimeSinceSignal function (ie 89 days for $DRI, and 23 for $CAG):

I also added a % of 20D Avg Vol column to show the if there was strong volume associated with the breakout. In the case of $DRI the volume was almost 3 times 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:

 

High within 1% of the previous pivot level

To find those stocks within 1% of the previous high level, thus approaching a significant level that you may wish to keep an eye on for a potential breakout:

 

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).

 

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 is in the process of studying for Level 3 of the CMT Program.

When not looking at charts, Darren 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.

4 Comments

  1. Avatar

    Hi Darren,
    Is it possible to script the difference between two Pivot Labels? I tried my below script but does not work:

    V1 = PIVOT(MIN=10, TYPE=High, DIR=Backwards);
    V3 = TIMESINCESIGNAL(V1);
    V1 – V1[V3]

    Reply
  2. Avatar

    Great work Darren! – this is something I’ve been trying to code for a while after reading more about chaos theory and fractal breaks by Bill Williams (he uses 4 bar fractals).

    On the back of your work I also tried to also include a time element to this code by using varying time length Donchian channels. The code I used:

    OPTEX(DEFAULT=Trend)=1;
    turtle1 = close()> donch(DEFAULT=CentreLine);
    turtle2 = close() CrossesAbove DONCH(BARS=21);
    NOREPEAT(turtle2, BARS=5)

    My results were ok-ish – I wanted to see if you had any thoughts on the code I used or how a Donchian channel might also be used to add a time layer to pivot breakouts.

    cheers

    Mandeep

    Reply
  3. Avatar

    Great work Darren! – this is one of the things I’ve been trying to code for a while based on my reading of the chaos theory and fractal breaks strategy by Bill Williams – he uses 4 bars on each side.

    The results are pretty impressive on the signal tester on a basket of FX pairs I trade: 63% probability, win-loss 2.5:1 when I combine with a trend filter and a momentum indicator.

    Just a query: the turtle trading system uses a similar approach using new highs with a Donchian channel. How could I validate this – I used the code close() Crossesabove Donch() and close() > Donch(centre line) but the results were not as good.

    Reply

Submit a Comment

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

Blog Signup

Pin It on Pinterest

Share This

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close