GannSwingEquality

Is it possible to write a script that would point out this GannSwingEquality on the attached chart?
Current Upswing length is equal to Previous Upswing length.

Hi David,

You can create formulas for any swing value. When added to a watchlist column the following will give the % value of the current swing relative to the previous swing in the same direction (ie up swing or down swing).

//Define swing criteria;
GS1 = GANNSWING(SWINGCOUNT=3, METHOD=Use Next Bar);
//Get current swing range; 
R1 = SWINGEND(GS1) - SWINGSTART(GS1);
//Get previous (same direction) swing range;
R2 = SWINGEND(GS1)[2] - SWINGSTART(GS1)[2];
//Calculate ratio;
R1/R2

So GS is currently 99.07% of the previous swing up (confirmed with the Price Extension P/X label on the overlay tool).

Capture

Make the formula into a true/false Boolean and you can then use it in a scan, eg swing ranges within a ±2% tolerance:

R3 = R1/R2;
R3 > 0.98 and R3 < 1.02

This scan of the S&P500 shows these 6 as of Monday’s close:

Capture

That’s great! Thanks so much, Darren.

//Define swing criteria; 
PS1 = PERCENTSWING(PERCENT=.25); 
//Get current swing range; 
R1 = SWINGEND(PS1) - SWINGSTART(PS1); 
//Get previous (same direction) swing range; 
R2 = SWINGEND(PS1)[2] - SWINGSTART(PS1)[2];
 //Calculate ratio; 
R1/R2

This is the code I am using in a watchlist with a 60 minute timeframe called
“EqualityPercentSwing”. When the swings change it goes to zero. (Please
see attached.) For it to
get off zero I have to manually refresh the list by changing the timeframe
from 60 minute to 30 minute. Is there any way for this code to update the
value on its own after reaching a new swing end? If not, is there a way to
have the watchlist automatically refresh?

Screenshot-2021-06-16-062246.png

Is there a way to do the same thing but instead of the swing length in points
using the number of bars in the swing?