App-Chart
view release on metacpan or search on metacpan
lib/App/Chart/Series/Derived/RWI.pm view on Meta::CPAN
# Copyright 2006, 2007, 2009, 2010 Kevin Ryde
# This file is part of Chart.
#
# Chart is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3, or (at your option) any later version.
#
# Chart is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with Chart. If not, see <http://www.gnu.org/licenses/>.
package App::Chart::Series::Derived::RWI;
use 5.010;
use strict;
use warnings;
use Carp;
use List::Util qw(min max);
use Locale::TextDomain ('App-Chart');
use base 'App::Chart::Series::Indicator';
use App::Chart::Series::Derived::MFI;
use App::Chart::Series::Derived::TrueRange;
# http://store.traders.com/-v10-c01-sideran-pdf.html
# Abstract of sidebar calculation, excess of channel height (scaled by
# one-day move) over square root.
# http://store.traders.com/-v11-c11-sideran-pdf.html
# Similar.
# "Are There Persistent Cycles", E. Michael Poulos, September 1992
# TASC.
#
# http://www.prophet.net/analyze/popglossary.jsp?studyid=RWI
# Sample of McDonalds, year not shown but looks like May 2001.
#
# http://www.paritech.com/paritech-site/education/technical/indicators/momentum/random.asp
# Description, no formulas, sample of DJS.AX, year not shown but is
# 1999 (RWI period not shown either).
#
# http://trader.online.pl/MSZ/e-w-Random_Walk_Index.html
# Formula.
#
# http://trader.online.pl/MSZ/e-w-Random_Walk_Index_II.html
# Long and short term high and low forms. Chart of Telecom Polska
# (TPSA.WA, London international order book TPSD.IL).
#
# http://www.linnsoft.com/tour/techind/ranWalk.htm
# Formula.
#
# http://www.equis.com/customer/resources/formulas/formula.aspx?Id=48
# Metastock formula, but only the RWI High part
#
# http://xeatrade.com/trading/2/R/1160.html
# Metastock formula.
#
# http://www.tradecision.com/support/indicators/random_walk_index.htm
# Tradedecsion formula for 9-day, cumulative sum of 1-day ATRs.
#
# http://technical.traders.com/tradersonline/display.asp?art=606
# Dennis Peterson on a random walk trading system. Sample Nasdaq
# composite (QQQ, yahoo now ^IXIC) from 1999/2000.
#
# http://www.sirtrade.com/serv03.htm
# Sample code of programming service by Pierre Orphelin, having
# struggled a bit with the correct definition. (Rejected incorrect
# code using the highest high in the past N days, maybe.)
#
# http://www.biz-analyst.com/library/stocks_commodities_trend.pdf
# Copies of some TASC articles, including "Futures According to Trend
# Tendency" V.10:1 by Michael Poulos, which includes a sidebar on his
# RWI. (Doesn't specify SMA or EMA for average.)
#
# http://ta-glossary.netfirms.com/taglossary-R.htm
# Description, sample Bradley Pharma (NYSE symbol BDY) from 2004.
#
# http://www.wallstreettape.com/tutorials/ta/c37.asp
# Chartfilter description.
#
#
sub longname { __('RWI - Random Walk Index') }
sub shortname { __('RWI') }
sub manual { __p('manual-node','Random Walk Index') }
use constant
{ type => 'indicator',
units => 'rwi',
minimum => 0,
hlines => [ 1 ],
parameter_info => [ { name => __('Days'),
key => 'rwi_days',
type => 'integer',
minimum => 1,
default => 9 } ],
line_colours => { high => App::Chart::UP_COLOUR(),
low => App::Chart::DOWN_COLOUR() },
};
sub new {
my ($class, $parent, $N) = @_;
$N //= parameter_info()->[0]->{'default'};
($N >= 1) || croak "RWI bad N: $N";
return $class->SUPER::new
(parent => $parent,
parameters => [ $N ],
arrays => { high => [],
low => [] },
array_aliases => { values => 'high' });
}
*warmup_count = \&App::Chart::Series::Derived::MFI::warmup_count; # $N
sub proc {
my ($class_or_self, $N) = @_;
my $tr_proc = App::Chart::Series::Derived::TrueRange->proc;
my (@H, @L, @TR, $prev_tr);
( run in 0.611 second using v1.01-cache-2.11-cpan-39bf76dae61 )