| SID Name | Description | Rating |  | 846 DownBar | DownBar Returns 1 if the bar is a DownBar, 0 if not. You define what a DownBar is by specifying one or more columns as arguments. If you want to look for lower closes, then specify DownBar(Close). If you require a DownBar to be both lower highs and lo | Not Approved |
 | The logic for this technical analysis indicator: |
#DownBar
#
# Returns 1 if the bar is a DownBar, 0 if not.
#
# Accepts up to four columns as arguments. Only one column is compulsory. For the bar to be considered a DownBar,
# all of the passed arguments must have a value lower than the value on the previous bar.
# The use of optional paramters allows this indicator to flag lower highs, or lower highs and lower lows, for example.
# Passing one column (e.g. Low) just looks for lower lows. Passing (High,Low) returns 1 if both the high and low are lower.
my ($Column1, $Column2, $Column3, $Column4) = @_;
my $NumColumns = 1;
ValidateColumns($Column1);
my $DownCount = 0;
$DownCount = If ($Column1 < Ref($Column1,-1),$DownCount = $DownCount + 1,0);
if ($Column2 > 0)
{
ValidateColumns($Column2);
$NumColumns = $NumColumns + 1;
$DownCount = If ($Column2 < Ref($Column2,-1),$DownCount = $DownCount + 1,0);
}
if ($Column3 > 0)
{
ValidateColumns($Column3);
$DownCount = If ($Column3 < Ref($Column3,-1),$DownCount = $DownCount + 1,0);
$NumColumns = $NumColumns + 1;
}
if ($Column4 > 0)
{
ValidateColumns($Column4);
$DownCount = If ($Column4 < Ref($Column4,-1),$DownCount = $DownCount + 1,0);
$NumColumns = $NumColumns + 1;
}
my $DownBar = If($DownCount == $NumColumns,1,0);
|