On a Gann Swing Chart, I’d like to be able identify gaps in the swing, such as the one pictured below. These sort of gaps often, but not always, indicate a change of trend or strengthening of a trend.
In the first example attached, there was an initial slow and steady uptrend (a few higher swing highs and higher swing lows), then after the gap, the uptrend accelerated. The gap can be an early clue that sentiment has shifted. The swing down that created the gap was < 50%, which can be another clue as to strength.
A second example is also attached.
I’ve looked at the GANNSWING() function and the inbuilt scripts, Gann Swing Bull Gap Greater and Gann Swing Bull Gap Less but they don’t seem to be written to identify gaps.
Not sure where to start with this but hopefully someone can help.
The first thing I always do with Swings is draw out the pattern I am interested in and then number the swings. Remember that it is not until the last swing turns up that we will have our signal, so that is where we expect to see the arrow. In the image below I have my numbers just to the left of each line.
Also, remember that we can reference previous swings by using square brackets. If there are no square brackets, I am working with the last swing line (0). I use the variables “g1” to make the script easier to read.
Given that, the code will be
// add the swing to the variable g1
g1 = GANNSWING(SWINGCOUNT=2, USEINSIDE=True);
// is swing line 0 up
c1 = SwingEnd(g1) > SwingStart(g1);
// is the start of swing 0 higher than the start of swing 3
c2 = SwingStart(g1) > SwingStart(g1[3]);
c1 and c2
Mathew, your tip on numbering the swings seems obvious when you point it out!
I tested the script on a small workbook in which there were 4 known Swing gaps, and this identified all 4. Results varied depending on whether SWINGCOUNT = 1 or SWINGCOUNT = 2 was used.
Tim, your script identified 2 of the 4 gaps, but I haven’t yet delved into it to see what might need changing.