closing_values array must have 28 values?

71 views
Skip to first unread message

cory

unread,
Jan 17, 2010, 1:15:13 PM1/17/10
to stockmonkey
Below is my module for RSI. Basically I download a cvs file for each
stock and store it in /tmp/stockdata/$symbol

I then use this module to open the file and grab the closing price for
the past 28 days and then send that array to rsi-insert.

My question is this. Has anyone else noticed that closing_values
array must have 28 values, anything less will return null value for
$q.

Also, I seem to be getting different values for 14 day RSI. It is not
matching with stockcharts.com or finance.google.com or
finance.yahoo.com


package rsi;

use strict;
use warnings;
use Math::Business::RSI;

sub conrsi {

my $nofile = shift;
my $file = shift;
chomp $file;

my $rsi = new Math::Business::RSI;
$rsi->set_days(14);

open(F, '<', "/tmp/stockdata/$file") || die "Couldn't open the current
file: $file $!";
my @CSV = <F>;
close (F);

my $lines;
my $TOTAL;
my @cvl;
my $q;
my @closing_values;
my $i;
for $i (1 .. 28) {
$lines = $CSV[$i];
@cvl = split(/,/, $lines);
$TOTAL = $cvl[4];
push(@closing_values, $TOTAL);
# print "<br>value $i $TOTAL";
$i++;
}

#@closing_values = reverse(@closing_values);
$rsi->insert( @closing_values );
$q = $rsi->query;

return ($q, $file);
}
1;

Paul Miller

unread,
Jan 17, 2010, 4:32:15 PM1/17/10
to stockmonkey
Again, it should only take 15 — not 28. Also, feed it a year's worth
of data and it'll be a lot closer to what yahoo and google have for it.
Reply all
Reply to author
Forward
0 new messages