Optuma Swing Charts: Finding Patterns
Why is this important? As discussed in the other articles, swing charts make it easy to see trends and strength in the market, so these formulas can help you quickly and easily find particular setups based on changes in trend.
Let’s start off by finding the previous swing values using the SWINGSTART function and offsets.
When looking at swing values it’s important to know the current swing direction.
This means that the same script can return different results if the current direction isn’t taken into consideration. If the current swing is up, then the SwingStart value will be a low, and if the swing is down then it will be a high. Likewise, the offset swing values will be different, so the previous swing start will be a high when the current swing is up, and a low with a downswing.
The image below shows the swing high and low values for ANZ on the left (current swing is up) and AMC on the right (swing down).
Click images to enlarge.
As you can see, the swing offsets on the left have an even number for the lows (ie S[2], S[4], and S[6]) versus odd numbers on the right (ie S[1], S[3], and S[5]).
Here are the scripts, based on a 3 bar Gann Swing:
Current Swing End:
1 2 3 4 |
SW1 = GANNSWING(SWINGCOUNT=3, METHOD=Use Next Bar, USEINSIDE=True); SWINGEND(SW1) |
Swing Start:
1 2 3 4 |
SW1 = GANNSWING(SWINGCOUNT=3, METHOD=Use Next Bar, USEINSIDE=True); SWINGSTART(SW1) |
Previous Swing Start – S[1]
1 2 3 4 |
SW1 = GANNSWING(SWINGCOUNT=3, METHOD=Use Next Bar, USEINSIDE=True); SWINGSTART(SW1)[1] |
To get preceding swings start levels increase the offset value in the square brackets, ie [2], [3], etc.
Finding Swing Patterns
So now we know the swing values (and offsets) we can look for relationships between the swings. For example, you can scan for when a stock is in an upswing with at least two consecutive higher swing lows:
1 2 3 4 5 |
SW1 = GANNSWING(SWINGCOUNT=3, METHOD=Use Next Bar, USEINSIDE=True); S1 = SWINGSTART(SW1); SWINGUP(SW1) and (S1 > S1[2]) and (S1[2] > S1[4]) |
To find two consecutive lower highs with a swing down:
1 2 3 4 5 |
SW1 = GANNSWING(SWINGCOUNT=3, METHOD=Use Next Bar, USEINSIDE=True); S1 = SWINGSTART(SW1); SWINGDOWN(SW1) and (S1 < S1[2]) and (S1[2] < S1[4]) |
In this example of the ASX200 watchlist, SFR (and 8 others) has at least two higher swing lows, and WOW (and 14 others) with at least two lower highs.
This next example which shows in a watchlist when the latest bar has changed the 10% swing direction from down to up:
1 2 3 4 |
SW1 = PERCENTSWING(PERCENT=10.0); SW1 TurnsUp |
This is useful, but what is more interesting – and potentially shows more strength – is if the new confirmed swing low is higher than than the previous low:
1 2 3 4 5 |
SW1 = PERCENTSWING(PERCENT=10.0); S1 = SWINGSTART(SW1); SW1 TurnsUp and (S1 > S1[2]) |
The third column takes it one step further: not only a higher low but also a new higher high:
1 2 3 4 5 6 |
SW1 = PERCENTSWING(PERCENT=10.0); S1 = SWINGSTART(SW1); E1 = SWINGEND(SW1); SW1 TurnsUp and (S1 > S1[2]) and (E1 > E1[2]) |
In the image below there were 21 members of the S&P500 whose 10% swing direction turned positive with the day’s price action, of which 11 formed a higher low, and only UHS formed a higher low and a higher high (albeit by only $0.12 – so if you wanted a percentage tolerance could be included in the formula):
Swing gaps
Finally, this will find instances when the last swing low is at least 2% higher than the previous swing high (which requires an offset of 3 in an upswing).
1 2 3 4 5 |
SW1 = GANNSWING(SWINGCOUNT=3, METHOD=Use Next Bar); S1 = SWINGSTART(SW1); SWINGUP(SW1) and (S1 > S1[3]*1.02) |
2% Swing Gap down:
1 2 3 4 5 |
SW1 = GANNSWING(SWINGCOUNT=3, METHOD=Use Next Bar); S1 = SWINGSTART(SW1); SWINGDOWN(SW1) and (S1 < S1[3]*0.98) |
If you have any questions about building your own formulas – not just on swings but on any other technical condition – please search the Scripting Forum and post queries there (provide as much information as you can – images are especially helpful). Alternatively, paid consultations can be arranged where we can build and test the formulas for you. Contact support for details.
Share Link

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.
0 Comments