help adding dates to swing points in amibroker afl

#1
can someone please add dates to each zig zag high and low points the
code is as follows

ZZPercent = Param("ZZPercent", 5 );
ATRPeriod = Param("ATRPeriod", 5 );
ATRFactor = Param("ATRFactor", 1.5, 0, 5 );

HLPivot = ZZPercent * 0.01 + ATRFactor * ATR( ATRPeriod )/Close;

Ll = Low[ 0 ];
Hh = High[ 0 ];
Llb = Lhb = 0;

if( High[ 1 ] >= Hh )
{
Hh = High[ 1 ];
Lhb = trend = 1;
}
else
{
Ll = Low[ 1 ];
Llb = 1;
trend = -1;
}

Line = Null;

for( i = 2; i < BarCount; i++ )
{
if( trend > 0 )
{
if( High[ i ] >= Hh )
{
Hh = High[ i ];
Lhb = i;
Curline = LineArray( Llb, Ll, Lhb, Hh );
Line = IIf( IsNull( CurLine ), Line, CurLine );
}
else
if( Low[ i ] < Hh - Hh * HLPivot[ i ] )
{
Ll = Low[ i ];
Llb = i;
trend = -1;
CurLine = LineArray( Lhb, Hh, Llb, Ll );
Line = IIf( IsNull( CurLine ), Line, CurLine );
}
}
else
{
if( Low[ i ] <= Ll )
{
Ll = Low[ i ];
Llb = i;
CurLine = LineArray( Lhb, Hh, Llb, Ll );
Line = IIf( IsNull( CurLine ), Line, CurLine );
}
else
if( High[ i ] > Ll + Ll * HLPivot[ i ] )
{
Hh = High[ i ];
lhb = i;
trend = 1;
CurLine = LineArray( Llb, Ll, Lhb, Hh );
Line = IIf( IsNull( CurLine ), Line, CurLine );
}
}
}

Plot( Line, "", colorBlueGrey, styleThick );
Plot( Close, Date()+ " Close", colorDefault, styleCandle );
 
#5
can someone please add dates to each zig zag high and low points the
code is as follows

ZZPercent = Param("ZZPercent", 5 );
ATRPeriod = Param("ATRPeriod", 5 );
ATRFactor = Param("ATRFactor", 1.5, 0, 5 );

HLPivot = ZZPercent * 0.01 + ATRFactor * ATR( ATRPeriod )/Close;

Ll = Low[ 0 ];
Hh = High[ 0 ];
Llb = Lhb = 0;

if( High[ 1 ] >= Hh )
{
Hh = High[ 1 ];
Lhb = trend = 1;
}
else
{
Ll = Low[ 1 ];
Llb = 1;
trend = -1;
}

Line = Null;

for( i = 2; i < BarCount; i++ )
{
if( trend > 0 )
{
if( High[ i ] >= Hh )
{
Hh = High[ i ];
Lhb = i;
Curline = LineArray( Llb, Ll, Lhb, Hh );
Line = IIf( IsNull( CurLine ), Line, CurLine );
}
else
if( Low[ i ] < Hh - Hh * HLPivot[ i ] )
{
Ll = Low[ i ];
Llb = i;
trend = -1;
CurLine = LineArray( Lhb, Hh, Llb, Ll );
Line = IIf( IsNull( CurLine ), Line, CurLine );
}
}
else
{
if( Low[ i ] <= Ll )
{
Ll = Low[ i ];
Llb = i;
CurLine = LineArray( Lhb, Hh, Llb, Ll );
Line = IIf( IsNull( CurLine ), Line, CurLine );
}
else
if( High[ i ] > Ll + Ll * HLPivot[ i ] )
{
Hh = High[ i ];
lhb = i;
trend = 1;
CurLine = LineArray( Llb, Ll, Lhb, Hh );
Line = IIf( IsNull( CurLine ), Line, CurLine );
}
}
}

Plot( Line, "", colorBlueGrey, styleThick );
Plot( Close, Date()+ " Close", colorDefault, styleCandle );
Try not to use a zig-zag for detecting peaks and troughs, you are forcing the recognition of a certain % swing+zig-zag looks into the future, instead you may look at using fractals of different bar strengths for "following" the market. The AFL function for Date and time at peaks and troughs will depend on which version of Amibroker you are using !!
 

Similar threads

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?