Topic: Fractals
FSB uses 7 types of fractals
for(int iBar=8; iBar<Bars-1; iBar++)
{
if(High[iBar-1]<High[iBar-2] && High[iBar]<High[iBar-2])
{
// Fractal type 1
if( High[iBar-4]<High[iBar-2] &&
High[iBar-3]<High[iBar-2] )
afFrUp[iBar+1]=High[iBar-2];
// Fractal type 2
if( High[iBar-5]< High[iBar-2] &&
High[iBar-4]< High[iBar-2] &&
High[iBar-3]==High[iBar-2] )
afFrUp[iBar+1]=High[iBar-2];
// Fractal type 3, 4
if( High[iBar-6]< High[iBar-2] &&
High[iBar-5]< High[iBar-2] &&
High[iBar-4]==High[iBar-2] &&
High[iBar-3]<=High[iBar-2] )
afFrUp[iBar+1]=High[iBar-2];
// Fractal type 5
if( High[iBar-7]< High[iBar-2] &&
High[iBar-6]< High[iBar-2] &&
High[iBar-5]==High[iBar-2] &&
High[iBar-4]< High[iBar-2] &&
High[iBar-3]==High[iBar-2] )
afFrUp[iBar+1]=High[iBar-2];
// Fractal type 6
if( High[iBar-7]< High[iBar-2] &&
High[iBar-6]< High[iBar-2] &&
High[iBar-5]==High[iBar-2] &&
High[iBar-4]==High[iBar-2] &&
High[iBar-3]< High[iBar-2] )
afFrUp[iBar+1]=High[iBar-2];
// Fractal type 7
if( High[iBar-8]< High[iBar-2] &&
High[iBar-7]< High[iBar-2] &&
High[iBar-6]==High[iBar-2] &&
High[iBar-5]< High[iBar-2] &&
High[iBar-4]==High[iBar-2] &&
High[iBar-3]< High[iBar-2] )
afFrUp[iBar+1]=High[iBar-2];
}
if(Low[iBar-1]>Low[iBar-2] && Low[iBar]>Low[iBar-2])
{
// Fractal type 1
if( Low[iBar-4]>Low[iBar-2] &&
Low[iBar-3]>Low[iBar-2] )
afFrDn[iBar+1]=Low[iBar-2];
// Fractal type 2
if( Low[iBar-5]> Low[iBar-2] &&
Low[iBar-4]> Low[iBar-2] &&
Low[iBar-3]==Low[iBar-2] )
afFrDn[iBar+1]=Low[iBar-2];
// Fractal type 3, 4
if( Low[iBar-6]> Low[iBar-2] &&
Low[iBar-5]> Low[iBar-2] &&
Low[iBar-4]==Low[iBar-2] &&
Low[iBar-3]>=Low[iBar-2] )
afFrDn[iBar+1]=Low[iBar-2];
// Fractal type 5
if( Low[iBar-7]> Low[iBar-2] &&
Low[iBar-6]> Low[iBar-2] &&
Low[iBar-5]==Low[iBar-2] &&
Low[iBar-4]> Low[iBar-2] &&
Low[iBar-3]==Low[iBar-2] )
afFrDn[iBar+1]=Low[iBar-2];
// Fractal type 6
if( Low[iBar-7]> Low[iBar-2] &&
Low[iBar-6]> Low[iBar-2] &&
Low[iBar-5]==Low[iBar-2] &&
Low[iBar-4]==Low[iBar-2] &&
Low[iBar-3]> Low[iBar-2] )
afFrDn[iBar+1]=Low[iBar-2];
// Fractal type 7
if( Low[iBar-8]> Low[iBar-2] &&
Low[iBar-7]> Low[iBar-2] &&
Low[iBar-6]==Low[iBar-2] &&
Low[iBar-5]> Low[iBar-2] &&
Low[iBar-4]==Low[iBar-2] &&
Low[iBar-3]> Low[iBar-2] )
afFrDn[iBar+1]=Low[iBar-2];
}
}