PureBytes Links
Trading Reference Links
|
// ZigZag Hi Lo
/*
This should take care of it. It is a combination of 2 existing posts:
One buried in a Reinsley afl and one by Tomasz.
The Zig in the Reinsley post is an elegant modification of the existing
AB Zig and uses H and L, rather than only one parameter(e.g. H and L
instead of C,H,or L) and was selected over other H_l based Zigs for
reasons explained in another post.
(Minor) errors in both of them were corrected and some enhancements were
incorporated.
Play with the parameters and adjust or throw out what you don't need or
want.
*/
_SECTION_BEGIN( "ZigZag" );
//added
Title = EncodeColor( 4 ) + _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 ) ) );
SetChartOptions( 0, chartShowArrows | chartShowDates );
Plot( C, "", 1, 64 );
//from Reinsley
ZigPerc = Param( "ZigZag-HL %", 0.02, 0.01, 10, 0.01 );
HHLLSel = ParamToggle( "Each Pk/Tr|HH/LL", "Each Pk/Tr|HH/LL Only", 1 );
Both_Versions = ParamToggle( "Modified Only|Both", "Modified Only|Both",
1 );
ATRmult = Param( "Text Shift (in ATR)", 0.6, 0.1, 3, 0.1 );
Show_Arrows = ParamToggle( "Show Arrows", "No|Yes", 1 );
Arrowadj = Param( "Arrowadj; ", 12, 2, 25, 1 );
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;
zp1 = IIf( pk, zHi, IIf( tr, zLo, IIf( HLAvg > Ref( HLAvg, -1 ), H, L )
) ); //Reinsley original
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
//=========Modified version================
za2 = Zig( zp2, ZigPerc );
Slopeza2 = za2 - Ref( za2, -1 );
Plot( za2, "\nZig Modified", 11, 5 | styleNoLabel );//Zig H-L Modified
if ( Show_Arrows )
{
pR = Ref( za2, -1 )<za2 AND za2>Ref( za2, 1 );
pS = Ref( za2, -1 ) > za2 AND za2 < Ref( za2, 1 );
PlotShapes( shapeDownArrow*pR, colorGreen, 0, H, -Arrowadj );
PlotShapes( shapeUpArrow*pS, colorRed, 0, L, -Arrowadj );
}
if ( Both_Versions )
{
// Original Reinsley Version=================
za1 = Zig( zp1, ZigPerc );
Slopeza1 = za1 - Ref( za1, -1 );
Plot( za1, "ZiG Original", 1, 5 | styleNoLabel );//Zig H-L Reinsley
original
if ( Show_Arrows )
{
pR = Ref( za1, -1 )<za1 AND za1>Ref( za1, 1 );
pS = Ref( za1, -1 ) > za1 AND za1 < Ref( za1, 1 );
PlotShapes( shapeDownArrow*pR, colorGreen, 0, H, -Arrowadj );
PlotShapes( shapeUpArrow*pS, colorRed, 0, L, -Arrowadj );
}
}
//za2 = IIf(Slopeza1 >0 AND Slopeza2>0,Max(za1,za2),IIf(Slopeza1 <0 AND
Slopeza2<0,Min(za1,za2),za2));
//Plot(za2,"",11,5|styleNoLabel);//Zig H-L
//modified from Tomasco
// ORIGINAL uses H AND L values for next bar after Zig pk/tr instead at
Zig pk/tr and is based on Zig(C);
// occasionally, that value is lower/higher than the correct ZigLo/ZigHi
values, since the Zig is based on C, NOT on H and L
//added additional bells and whistles
if ( HHLLSel )
{
HH = ( ( za2 > Ref( za2, - 1 ) AND za2 > Ref( za2, 1 ) ) AND (
Peak( za2, ZigPerc, 1 ) > Peak( za2, ZigPerc, 2 ) ) ); //HH
LL = ( ( za2 < Ref( za2, - 1 ) AND za2 < Ref( za2, 1 ) ) AND (
Trough( za2, ZigPerc, 1 ) < Trough( za2, ZigPerc, 2 ) ) ); //LL
dist = ATRmult * ATR ( 20 );//might not want that
for ( i = 0; i < BarCount; i++ )
{
if ( HH [i] )
PlotText( "HH" + "\n" + H[ i ], i, H[ i ] + dist[i],
colorGreen );
if ( LL [i] )
PlotText( "" + L[ i ] + "\nLL", i, L[ i ] - dist[i],
colorRed );
}
}
if ( !HHLLSel )
{
HH = ( ( za2 > Ref( za2, - 1 ) AND za2 > Ref( za2, 1 ) ) );
LL = ( ( za2 < Ref( za2, - 1 ) AND za2 < Ref( za2, 1 ) ) );
}
dist = ATRmult * ATR ( 20 );//might not want that
for ( i = 0; i < BarCount; i++ )
{
if ( HH [i] )
PlotText( "H" + "\n" + H[ i ], i, H[ i ] + dist[i], colorGreen );
if ( LL [i] )
PlotText( "" + L[ i ] + "\nL", i, L[ i ] - dist[i], colorRed );
}
/* Original
HH=((za2<Ref(za2,- 1) AND Ref(za2,-1) > Ref(za2,-2)) AND
(Peak(za2,ZigPerc,1 )>Peak(za2,ZigPerc,2 )));
LL=((za2>Ref(za2,- 1) AND Ref(za2,-1) < Ref(za2,-2)) AND
(Trough(za2,ZigPerc,1 ) <Trough(za2,ZigPerc,2 )));
*/
_SECTION_END();
prasantaroy36 a écrit :
>
>
> dear friends
>
> i want zigzag afl which connect top & bottom and working also in
> intraday any time frame.
>
> thanks
>
>
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
amibroker-digest@xxxxxxxxxxxxxxx
amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|