NthLowestBar:
I did not manage to code NthLowestBar. So in the EL code where NthLowestBar is used, I use something else.
A short description:
" A TestBar is a bar that breaks previous support or resistance and then rebounds in the other direction. In a bullish TestBar, the bar breaks below a previous low (cannot be the low of one bar ago) and closes in its top half range."
EL code:
{AcmeTest}
Variables:
Length(20),
SeparationBars(2);
AcmeTest = 0;
If Low < Lowest( Low, Length-1)[1] and
NthLowestBar(2, Low, Length) >= SeparationBars and
AcmeRangePercent( Close, 1) > 0.5 Then
AcmeTest = 1;
AFL code:
function NthLV( array, period, nth ) {
return Percentile( array, period, (nth - 1) / (period - 1) * 100 );
}
function AcmeTest()
{
// local variables
length = 20;
previous_1stLowestLow = Ref( NthLV( L, length-1, 1), -1);
previous_2ndLowestLow = Ref( NthLV( L, length-1, 2), -1);
return
// bar breaks below a previous lowest Low
L < previous_1stLowestLow
AND
// the 2nd lowest Low is more than two bars away
Ref( L, -1) != previous_2ndLowestLow
AND
Ref( L, -2) != previous_2ndLowestLow
AND
// Close is in the top half of the range
AcmeRangePercent( C, 1) > 0.5;
}
AcmeRangePercent function tells where in the range (H-L) the close is.
Please comment, I appreaciate it. I haven't used AFL for a while so I'm "rusty".
Regards,
Wolfgang