Gann Swing Retracement scan

The following formula will return results where the current retracement is 50% (+/- 2%) of the previous downswing, based on a 3 Bar Gann Swing method to determine the swings:

//Set Swing properties and get the swing start and end values
GS1 = GANNSWING(SWINGCOUNT=3,METHOD=USE NEXT BAR);
SS1 = SWINGSTART(GS1);
SE1 = SWINGEND(GS1);

//Calculate previous swing range
V1=(SWINGSTART(GS1)[1] - SWINGEND(GS1)[1]) ;
//Set 2% tolerance
V2 = SS1 + (V1 * 0.48);
V3 = SS1 + (V1 * 0.52);
//Is Scurrent wingEnd within the tolerance?
SWINGEND(GS1) > V2 and
SWINGEND(GS1) < V3