Mathew Verdouw's Gann Swing indicator not working as in the video

I’m new to Optuma. As a learning exercise, I’m working to replicate the Gann swings script that Mathew Verdouw created in his “Gann Swings Part 2” video from 2017. By about the midpoint of the video the script Mathew’s built is as follows:

  2. g2 = GANNSWING(Week(),USEINSIDE=True, METHOD=Use Next Bar)
  3. e1 = SWINGEND(g1);
  4. c1 = HIGH() CrossesAbove e1[1];
  5. c2 = e1[2] < e1[1];
  6. c3 = (e1[5] > e1[3] )and (e1[3] > e1[1] );
  7. c5 = g2 IsUp;
  8. c4 = c1 and c2 and c3 and c5;
  9. NOREPEAT(c4, BARS=7)

The script works as expected for me up to the point where the functionality is added to allow the signal to trigger only when the weekly Gann swing IsUp (see code in lines 2 & 7 and the addition of “and c5” in line 8). When that additional code is added the signal stops triggering at all, even during periods when the weekly Gann swing is up as indicated by a Show View programmed as “GANNSWING(Week(),USEINSIDE=True, METHOD=Use Next Bar) IsUp”.

For example, I’ve verified this using a daily chart of MSFT with a Show View added to show periods when the weekly Gann swing is up, as noted just above. When line 2 is commented out of the Show Bar using “//” and “and c5” is removed from line 8, the signal is seen, for example, on January 31, 2022. The Show View confirms this date falls in a period during which the weekly Gann swing is up. However, when line 2 is uncommented back in and “and 5” added to line 8, the 1/31/22 signal disappears, even though that date is in a period in which the weekly Gann signal is up according to the Show View
Hopefully, I’ve explained this clearly enough. Can anyone tell me what might be the problem here and how to fix it?

Thanks very much,
Robert “Mick” McWilliams

Hi Mick,

I’m not seeing that issue here… (note that line g2 above does not end with a ; so make sure you add that).

When the ‘and c5’ is commented out the signal still shows for MSFT on Jan 31st 2022. Here’s the 2 different scripts in a Show View, with the C5 condition also shown in orange. You will notice the green signal does not occur on March 2nd because the weekly swing is down (ie C5 is false).

Here’s a workbook you can save and open containing the formulas.

MSFT Swings.owb (15.9 KB)

Thanks, Darren! Adding the “;” does, of course, resolve the issue. Clearly, I need to redouble efforts to check for the “small” details in a situation like this. Thanks again…

Perhaps it’s worth nothing though that the scripting editor did not recognize that missing “;” as an error as it didn’t show “invalid script” as I’ve noted that it most often does with such an error. Anyway, thanks again!