View Single Post
  #6 (permalink)  
Old 01-24-2007, 11:19 PM
apfx's Avatar
apfx apfx is offline
Junior Member
 
Join Date: Dec 2005
Posts: 18
apfx is on a distinguished road
Three Line Break

This is the code I wrote for TLB in AFL .
__________________________________________________ ___________

break = Param("Break", 3, 1, 5, 1);

tc[0]= L[0];
to[0]=H[0];
Line[0]=H[0];

j=0;
direction= 0;
down[0]=0;
up[0]=0;
for (i=1; i<BarCount; i++)
{

if (direction ==0)
{

if( C[i] <tc[j] )
{
j++;
down[j] = down[j-1]+1;
up[j]=0;
tc[j] =C[i];
to[j]=tc[j-1];
if(down[j]<break)
Line[j] =to[j-1];
else
Line[j] = to[j-break+1] ;

}
else
{

if(C[i]>Line[j])
{
j++;
down[j]=0;
up[j] =up[j-1]+1;
direction =1;
tc[j] =C[i];
to[j]=to[j-1];
if(break>1)
Line[j] = tc[j-1];
else
Line[j] =to[j];


}
}
}
else
{

if( C[i] >tc[j] )
{
j++;
down[j]=0;
up[j] =up[j-1]+1;
tc[j] =C[i];
to[j]=tc[j-1];
if(up[j]<break) Line[j] = to[j-1];
else Line[j] = to[j-break+1];


}
else
{
if(C[i]<Line[j] )
{
j++;
up[j]=0;
down[j] = down[j-1]+1;
direction =0;
tc[j] =C[i];
to[j]=to[j-1];
if(break>1) Line[j] = tc[j-1];
else Line[j] =to[j];


}
}

}


}

delta = BarCount-1 - j;
Cl= Ref(tc,-delta);
Op =Ref(tO,-delta);

PlotOHLC(Op,Cl,Op,Cl,"",colorBlack, styleCandle);
Reply With Quote