Hi!
I Use the zigzag-code below:
// ZigZag Hi Lo Barcount
// Modified version by Joris Schuller
// from ZigZag Hi Lo : simplified version
// mod by reinsley : swing bars count, ribbon
SetChartOptions( 0, chartShowArrows | chartShowDates );
Plot( C, "", 1, 64 );
Title = EncodeColor( 11 ) + _DEFAULT_NAME() + " : " + EncodeColor( 1 ) + StrFormat( "{{NAME}} - {{INTERVAL}}; {{DATE}}; \nO=%g, \nH=%g, \nL=%g, \nC=%g (%.1f%%){{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );
plt = ParamToggle( "Plot ZigHL ", "Off|On", 1 );
_SECTION_BEGIN( "ZigHiLo BarCount" );
ZigPerc = Param( "ZigZag-HL %", 0.22, 0.01, 10, 0.01 );
pk = PeakBars( H, ZigPerc ) == 0;
tr = TroughBars( L, ZigPerc ) == 0;
pkbars = PeakBars( H, ZigPerc );
trbars = TroughBars( L, ZigPerc );
zHi = Zig( H, ZigPerc );
zLo = Zig( L, ZigPerc );
HLAvg = ( zHi + zLo ) / 2;
zp2 = IIf( pk, zHi, IIf( tr, zLo, IIf( pkbars <= trbars, L, H ) ) );//Modified zp to reduce occasional erroneous Pk/Tr connections at very small ZigPerc values
za2 = Zig( zp2, ZigPerc );
Slopeza2 = za2 - Ref( za2, -1 );
if ( plt == 1 )
{
Plot( za2, "\nZig HiLo Modified (" + ZigPerc + ")", 11, 5 | styleNoLabel );//Zig H-L Modified
}
_SECTION_END();
upzig = za2 >= Ref( za2, -1 );
dnzig = za2 <= Ref( za2, -1 );
Peakzig = za2 > Ref( za2, -1 )AND za2 > Ref( za2, 1 );
Troughzig = za2 < Ref( za2, -1 )AND za2 < Ref( za2, 1 ) ;
BarsUp = BarsSince( dnzig );
BarsDn = BarsSince( upzig );
Colorzig = IIf( upzig , colorGreen, IIf( dnzig , colorRed, colorRed ) );
// Zig's ribbon
Ribbon = IIf( upzig , colorGreen, IIf( dnzig , colorRed, colorGreen ) );
Plot( 2, "", Ribbon , styleOwnScale | styleArea | styleNoLabel, 0, 100 );
// plot a text at X % from bottom's pane
percent = Param( "PositText%", 3, 0, 90, 0.5 );
Miny = Status( "axisminy" );
Maxy = Status( "axismaxy" );
y = Miny + ( Maxy - Miny ) * percent / 100; // at X % above bottom of the pane
begbar = Status( "firstvisiblebar" ) ;
PlotText( "Zig BC (" + ZigPerc + ")" , begbar + 3 , y - 7 , colorWhite );
for ( i = 0; i < BarCount; i++ )
{
if ( Peakzig [i] )
PlotText( "" + BarsUp [ i ], i - BarsUp [ i ] / 2 + 1, y, colorGreen );
if ( Troughzig [i] )
PlotText( "" + BarsDn [ i ], i - BarsDn [ i ] / 2 + 1, y, colorRed );
}
if ( LastValue( upzig ) )
PlotText( "" + LastValue( BarsUp ) , BarCount - 1 / 2 + 1, y, colorGreen );
else
PlotText( "" + LastValue( BarsDn ) , BarCount - 1 / 2 + 1, y, colorRed );
Filter = C > 0;
//Kop = IIf(Ref(za2,-2) < Ref(za2,-1) AND za2 > Ref(za2,-1),1,0);
//Kop = IIf (Barsup == 1 OR BarsUp == 2,1,0);
AddColumn(upzig, "upzig", 1.0);
AddColumn(dnzig, "dnzig", 1.0);
I want to add a column that shows the number in the picture below:
Anyone who could help me with this?
Best regards,
/Leif