Zig zag cum volume

Hi,

I've been playing around with an old code of reinsley's. Wave volume using zig zag. I'm trying to plot a shape when "current swing volume > previous swing volume and previous swing volume > swing volume before that...etc". I started writing something at line 69 (where the error shows) ...not sure what comes next. Grateful for any help please.





// cumulate the volume for each swing
 // by reinsley

 
 
_SECTION_BEGIN( "Price" );

GraphZOrder = True;  
  
SetChartOptions( 0, chartShowArrows | chartShowDates );
_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {7/06/2017} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) \n{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
																		
SetBarFillColor( IIf( C > O, ParamColor( "Candle UP Color", colorGreen ), IIf( C <= O, ParamColor( "Candle Down Color", colorRed ), colorlightGrey ) ) );
Plot( C, "", IIf( C > O, ParamColor( "Wick UP Color", colorDarkGreen ), IIf( C <= O, ParamColor( "Wick Down Color", colorDarkRed ), colorLightGrey ) ), styleBar, 0, 0, 0, 0 );
SetBarsRequired(sbrAll,sbrAll);
_SECTION_END();
 

 
// Zig-Hi-Zag-Lo formula
VolON = ParamToggle( "Plot Volume", "Off|On", 1 );
ZigON = ParamToggle( "Plot Zig", "Off|On", 1 );
pr = Param( "ZigZag change amount", 0.005, 0.005, 4, 0.0001 );
 
zzHiLo = Zig( c, pr );
zzup = zzHiLo > Ref( zzHiLo, -1 ) ;
zzdn = zzHiLo < Ref( zzHiLo, -1 );
ribboncol = IIf( zzup , colorlightgrey, colorlightgrey );

if ( ZigON == 1 )
    Plot( zzHiLo, "", ribboncol , styleNoLabel|stylethick );
 
//Swing Volume
PeakBar = PeakBars(C, pr);//== 0;  
TroughBar = TroughBars(C, pr) == 0;  
SwingBar =  IIf(zzup,PeakBar,troughbar) ;//
BarsInSwing = BarsSince(SwingBar)+ 1 ; 
///////////////////////////////////////
///////////////////////////////////////////

Volswing = Sum( V, BarsSince( zzup != Ref( zzup, -1 ) ) + 1 ) ;// /1000;

FirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status( "LastVisibleBar" );
TextOffset = 0.5 * ATR(2);  
 
for ( i = Firstvisiblebar + 1; i <= Lastvisiblebar AND i < BarCount - 1; i++ )
{
    if ( zzup [i] AND zzup [ i+1] == 0 )
    {
        if ( VolON == 1 )
        {
            PlotTextSetFont(StrFormat("%.0f", Volswing[i]),"Arial Bold", 8, i, H[i] + TextOffset[i], coloryellow, colordarkblue );  

        }
    }
 
    if ( zzup [i] == 0 AND zzup [ i+1] == 1 )
    {
        if ( VolON == 1 )
        {
            PlotTextSetFont(StrFormat("%.0f", Volswing[i]), "Arial Bold",8, i , L[i] - TextOffset[i],coloryellow, colordarkblue  );  

        }
    }
    
		if if ( VolON == 1 )
		{
			if (Volswing[i]......  //help!
    
}
 
if ( VolON == 1 )
{
    PlotText( "" + Volswing , i + 2  , zzHiLo[BarCount-1], LastValue( ribboncol
) );
}
 








This line is wrong, it should be

if( <condition(s)> )
{ 
// code
}

hi
Maybe we can give you little bit kick start here.
i would like to remind you that Peak() and Trough() has a third parameter

SYNTAX : Peak(ARRAY, change , n = 1)
n =1 would return the value of the most recent peak.
n =2 would return the value of the 2nd most recent peak.