RSI

774 views
Skip to first unread message

cory

unread,
Jan 14, 2010, 11:31:23 PM1/14/10
to stockmonkey
I downloaded this library and I'm not getting the correct data for any
of my stocks. Does anyone else have this problem?

Paul Miller

unread,
Jan 15, 2010, 6:42:33 AM1/15/10
to stockmonkey

On Jan 14, 11:31 pm, cory <cnsm...@gmail.com> wrote:
> I downloaded this library and I'm not getting the correct data for any
> of my stocks. Does anyone else have this problem?

I seem to get the correct RSI given the correct inputs. What happens
when it doesn't work? Are you comparing it to another RSI
calculation? Are you using the exact same input data?

Some of this may be covered in the FAQ: http://is.gd/6j6QH

On the other hand, if you found a bug, I'd want to get that fixed
immediately.

cory

unread,
Jan 16, 2010, 11:47:37 AM1/16/10
to stockmonkey
Here is what I do:

First I set the days to 14.

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


Then I get the historical data from finance.yahoo.com and I put the
closing price in an array and assign it to @closing_values.

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


Then I return $q.

$q does not match the same value as stockcharts.com givin days is
14.

RSI for OWW (orbitz) is 49.34 if you set days to 14. (as of saturday
jan 16)
However when I run my program $q = 33.


I also found that, at minimum, I have to give my array 28 values in
order for me to get a value back.

cory

unread,
Jan 17, 2010, 1:09:33 PM1/17/10
to stockmonkey
When I run my program using 14 days and compare it to stockcharts.com
RSI analysis of 14 days I get two different numbers.

Also, has anyone else had a problem with building the closing_values
array? For some reason I have to give the array at least 28 values,
otherwise it wont compute the RSI and returns nothing.


On Jan 15, 5:42 am, Paul Miller <jett...@gmail.com> wrote:

Paul Miller

unread,
Jan 17, 2010, 4:26:43 PM1/17/10
to stockmonkey
These problems have to do with the way the RSI is calculated. It's
sensitive to starting data, since it's designed to be a moving
average. If you want it to match stockcharts (or at least be a lot
closer); you'd want to feed like 3 or 5 months of data to a 14-day
average.

A 14-day RSI also needs 15 (not 28) values in order to calculate the
first RSI. It will differ wildly from an RSI that has been given a
great deal more than 15 points though. This is, again, because of how
it's calculated. If you follow Wilder's formula using a spreadsheet,
you'll see what I mean.

Anyway, try it with all 25s...

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

$rsi->insert( map {25} 1 .. 14 );
print "undefined, literally\n" unless defined( $rsi->query );
$rsi->insert( 25 );
print "ahh, here we go: ", $rsi->query, "\n";

Should give you undefined, literally (because it's not defined yet)
and then 99.009900990099.

Paul Miller

unread,
Jan 17, 2010, 4:29:19 PM1/17/10
to stockmonkey

On Jan 17, 4:26 pm, Paul Miller <jett...@gmail.com> wrote:
> my $rsi = Math::Business::RSI->new(14)


Oops, also, Wilder defines these in terms of "alpha," which is kindof
like inverse days.

It'd have to be this to work:

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

Reply all
Reply to author
Forward
0 new messages