NAGAYASU Yukinobu

NAME

Math::Business::Stochastic - Perl extension for calculate stochastic oscillator

SYNOPSIS

``````  use Math::Business::Stochastic;

my (\$k, \$d, \$sd) = (5, 3, 3);

set_days \$stoc \$k, \$d, \$sd;

my @high_values = qw(
3 5 5 6 6 5 7 5 8 5 7
8 6 8 6 8 7 8 8 9 8 9
);
my @low_values = qw(
2 4 3 5 3 5 3 4 5 3 4
4 5 6 6 6 6 6 7 7 6 7
);
my @close_values = qw(
3 4 4 5 6 5 6 5 5 5 5
6 6 6 6 7 7 7 8 8 8 8
);

for(my \$i=0 ; \$i<int(@close_values) ; \$i++) {
\$stoc->insert( \$high_values[\$i], \$low_values[\$i], \$close_values[\$i] );

if( defined \$stoc->query_k ) {
print "Stochastic k:  ", \$stoc->query_k,  "\n";
}
else {
print "Stochastic k:  n/a\n";
}
if( defined \$stoc->query_d ) {
print "Stochastic d:  ", \$stoc->query_d,  "\n";
}
else {
print "Stochastic d:  n/a\n";
}
if( defined \$stoc->query_sd ) {
print "Stochastic sd: ", \$stoc->query_sd,  "\n";
}
else {
print "Stochastic sd: n/a\n";
}
}

# you may use this to kick start
\$stoc->start_with( [@high_values], [@low_values], [@close_values] );``````