I've been trying to develop a script that will identify double tops and bottoms. I've been able to do this using the Gann Swing when the tops/bottoms are on immediately previous swings in the same direction, or a defined number of previous swings in the same direction (by nominating the number of tops/bottoms back), although this latter appraoch fails if there is a higher top between the "identified" double top.
Here is the situation I'm now trying to identify:
This is a 1-Day Chart with the 1-Day Gann Swing Overlay. I've marked a Double Top that I'd like to be able to identify with a script. Note that this double top has a number of lower 1-Day Gann Swing tops intervening.
What I want to be able to do is to identify double tops regardless of the number of lower swing tops there are between double top - a higher top between the "double top" must, of course, negate the "double top".
Any bright ideas on how I can achieve this?
You could use other swing tools to determine the double tops, such as the PERCENTSWING() function that will draw swings when the market moves at least x% in the opposite direction, or the VOLATILITYSWINGS() function that uses ATRs in its calculation (so take in to account volatility and adapt as new data comes in: click here to read more about volatility swings).
These will filter out the smaller Gann Swings and help identify the significant tops and bottoms, as per this example comparing the two on NCM:
They work the same as the GANNSWING() function so you can copy existing formulas and change the function accordingly to see when the current swing high is within a certain % of the previous swing.
I agree that PERCENTSWING() and VOLATILITYSWINGS() can be used to filter minor swings, but it will also filter any Double Tops/Bottoms that full within their parameter ranges.
Consider the following chart:
This chart has a 1-Day Gann Swing Overlay and 5% "PERCENTSWING(DEFAULT=SwingList, BARS=1, PERCENT=5.0, CALCUSINGTOOL=High/Low, COLOURSTYLE=Up/Down)" script as a SHOWPLOT (green Long Dash Dash).
Using the 5% Percent Swing as a filter the three Double Tops (within my+/-0.5% criteria) would have been ignored. I haven't tried, but suspect, the same limitation using VOLATILITYSWINGS().
Incidentally, how did you get your PERCENTSWING() plot to show the colours. I can only get the plot to show a single colour, even with the SHOWPLOT parameters set as follows:
I'm thinking I'll have to write a Pascal script to step from each Swing Top/Bottom and look forward to the next Top/Bottom at the same level to find the next Top/Bottom at the same level but without any intervening Tops/Bottoms. Then to repeat the process for every Top/Bottom.
Any more ideas to try?
I am able to achieve similar results by using the Chart Pattern Overlay tool and ChartPattern() script function for scans.
The Chart Pattern tool is based on Pivots Label tool and Pivot(). It utilizes the harmonic patterns including Gartley, Bat, Butterfly, Crab etc. Some tool info. here
The double top signal is closely matched with the Bearish Bat, Butterfly or Gartley pattern that represents a W shape.
Couple points to note:
- To increase the Tolerance % level to include more double top patterns.
- To increase Min Pivot to look for higher and significant Tops or reduce Min Pivot for closer double Tops.
Here is the script that I use :
BigTop = CHARTPATTERN(TOL=48, MIN=21, PATTERN1=False, PATTERN2=False, PATTERN9=True, PATTERN11=True, PATTERN15=True);
MidTop = CHARTPATTERN(TOL=60, MIN=15, PATTERN1=False, PATTERN2=False, PATTERN9=True, PATTERN11=True, PATTERN15=True);
SmallTop = CHARTPATTERN(TOL=60, MIN=6, PATTERN1=False, PATTERN2=False, PATTERN9=True, PATTERN11=True, PATTERN15=True);
BigTop or MidTop or SmallTop
Hopefully, this helps with what you are looking for.
DoubleTops.owb (19.4 KB)
Thanks Henry - I need to spend more time with that Chart Pattern Matcher tool!
Trevor - I would contend that those swing highs that you labelled in your image are not double tops in the generally accepted meaning of the term. Double tops - and bottoms - are usually found at the end of a strong moves, not in the middle. Anyway, maybe the pattern matcher will do what you need.
Oh and the Percent Swing Overlay is a standard tool not a Show Plot, so you can adjust the colours and other properties the same as a Gann Swing Overlay. Click here for info on the various swing overlay tools.
Thanks Henry, I've not tried the Chart Patterns tool thus far so I'll give it a go.
Thanks Darren, now I've got my Percent Swing Overlay looking like yours
I've now had a chance to try the Chart Patterns Overlay (and in scripts) with the following results. The chart shows the CPO using Henry's Big Top (Lime) and Small Top (Magenta) as both the overlay and ShowPlots.
It's getting close to what I'm trying to do, but:
- it misses some intervening double tops that are within the Tolerance/Pivot (and my % Range) criteria - note in each of the Small Top overlays;
- does not identify all the Small Tops - note in the Big Top overlay the Top immediately left of the Big Top ShowBar; and
- I've been unable to determine:
- a way to ascertain the price of the first Top in the Double Top pair and hence
- a way to limit the result based on the percent difference between the Tops - I want to limit that to 0.5%.
My primary objective is to identify Double Tops (Bottoms) using a script, regardless of whether they are at the end of major moves as per Daren's comment, or minor ones within up/down trends or across trend reversals. I can then evaluate the Trade Performance of the setup using defined Trade Entry and Management Criteria of the different patterns with other criteria added (such as period between the Tops, Stop Loss and Profit Exit settings) and produce numerical results for various markets, rather than just chart pattern displays. As an example of the results of my testing on chart patterns, here is my output for an outside Reversal Bar with a Long Entry:
The variation is pattern performance of the simple patterns I've tested thus far across my markets of interest has been very illuminating.
Any ideas on how to overcome the above noted limitations in identifying Double Tops/Bottoms is greatly appreciated.
In the 1.3 version update currently being worked on there is a new chart pattern tool / scan being introduced which allows greater flexibility in defining the pattern you are after.
After speaking with the developer on this new feature i believe it will be able to achieve the result you are after.
Thanks for the update. Any date available yet for the release of version 1.3.
By the way, I'm still using the v1.3Beta of MAALLTools and so far as I'm aware have had no issues with it