Counting Bars with TIMESINCESIGNAL()

Does anyone know what is happening here?

My aim is to count the number of Bars in a Gann upswing and downswing.

The essential part of the script is below:

g1 = GANNSWING(USEINSIDE=True);

e1 = SWINGEND(g1);

c1 = (TIMESINCESIGNAL(e1[2]) - TIMESINCESIGNAL(e1[3])) > 12;

c2 = (TIMESINCESIGNAL(e1[1]) - TIMESINCESIGNAL(e1[2])) < 12;

c1 and c2

The function TIMESINCESIGNAL() default setting is to count bars. However, it does not seem to work the way I expect. As a way to see what values are generated, I added the script to a Watch List Column. It produced numbers, but nothing made sense!

Does anyone know what is happening or is there another way to count bars in Gann Swings?

Cheers, Lester

Hi Lester,

There’s a function already available you can use to find the number of bars between each swing, it’s called SWINGSTAT()

https://help.optuma.com/kb/faq.php?id=988

Hi Matthew,

Thank you for pointing out the SWINGSTAT(). However I have tried using this function with the Gann Swing Function and I do not get any output values?

Cheers, Lester

Hi Lester,

Without an example of the script you are using there’s no way to identify the problem. You need to make sure you wrap the function around a GS variable and select the output you want (there are a number of options as per the KB article).

The example at the bottom of the article shows a bar count between swings which is what you were after.

If you are still having troubles post the script you are using and i can provide additional help.

Hi Matthew,

Thank you again for your suggestion.

I tried the function with this script. I have also added a diagram to show you my labeling.

g1 = GANNSWING(USEINSIDE=True);

e1 = SWINGEND(g1);

v0 = e1[0];

v1 = e1[1];

v2 = e1[2];

v3 = e1[3]; // Convert to Bars v4 = SWINGSTAT(v1, DEFAULT=Bars, SWINGS=1) - SWINGSTAT(v2, DEFAULT=Bars, SWINGS=1);

v5 = SWINGSTAT(v2, DEFAULT=Bars, SWINGS=1) - SWINGSTAT(v3, DEFAULT=Bars, SWINGS=1);

c0 = v0 IsUp;// A new GS has started

c1 = (v4 < 5 and v5 > 8);// DOWN SWING 2-1 IS LESS THAN 5 BARS & UP SWING 3-2 IS MORE THAN 8 BARS

c2 = v1 < v2; // 2nd lattest GS is Down

c3 = v2 > v3;// 3rd lattest GS is Up

 

c0 and c1 and c2 and c3

Regards, Lester

Hi Lester,

The SwingStat() function needs to be wrapped around a full Gann Swing function, Swing End / Start won’t work.

For example:

V1 = GANNSWING(SWINGCOUNT=3);
SWINGSTAT(V1, DEFAULT=Bars)

This will give you the bar count between each swing (of a 3 Bar Gann Swing chart).

Hi Matthew,

Thank you for sorting this out. Bars are now getting counted.

Regards, Lester