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 !!
 
#7
The first question is why do I want to force my views on the market ?What is so important about "ATR" ?
I follow the movement of the market which is shown by fractals!
Now for you to get the date and time -- read the manual -- date time format and you will be able to get the answer!
Below is the code snippet which I use to get the final plot on the chart - for you study the date time code - the below gives me the date and the time!!

Since u are using 6.20, I presume u have bought the software, good decision,suggest u upgrade to 6.28, do not upgrade to 6.30RC as there are issues, wait for the final ver 6.3!

// DATES & TIME of Pivots
dt = DateTime();
dtformat = "%d-%m-%Y \n%H:%M:%S";

for( i = 1; i <= lvb; i++ )

if( PlotDateTime )
{
var = DateTimeFormat(dtformat, dt);
if( pk ) PlotText( "" + var , i-2, HhL+125 , colorViolet );
if( tr ) PlotText( "" + var, i-2, LlL-125, colorViolet);

}
 

Similar threads

Broker Special Offers

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?