| 1 | # Copyright 2007, 2009, 2010 Kevin Ryde | ||
| 2 | |||
| 3 | # This file is part of Chart. | ||
| 4 | # | ||
| 5 | # Chart is free software; you can redistribute it and/or modify it under the | ||
| 6 | # terms of the GNU General Public License as published by the Free Software | ||
| 7 | # Foundation; either version 3, or (at your option) any later version. | ||
| 8 | # | ||
| 9 | # Chart is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| 10 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 11 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 12 | # details. | ||
| 13 | # | ||
| 14 | # You should have received a copy of the GNU General Public License along | ||
| 15 | # with Chart. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | |||
| 17 | package App::Chart::Series::Derived::MedianAverageAlpha; | ||
| 18 | use 5.010; | ||
| 19 | use strict; | ||
| 20 | use warnings; | ||
| 21 | use Carp; | ||
| 22 | use List::Util qw(min max); | ||
| 23 | use Locale::TextDomain ('App-Chart'); | ||
| 24 | |||
| 25 | use base 'App::Chart::Series::Indicator'; | ||
| 26 | use App::Chart::Series::Derived::MedianAverage; | ||
| 27 | |||
| 28 | |||
| 29 | sub longname { __('Median-Average - Alpha') } | ||
| 30 | sub shortname { __('Median-Average Alpha') } | ||
| 31 | sub manual { __p('manual-node','Median-Average Adaptive Filter') } | ||
| 32 | |||
| 33 | use constant | ||
| 34 | { type => 'indicator', | ||
| 35 | priority => -10, | ||
| 36 | units => 'ema_alpha', | ||
| 37 | minimum => 0, # actually only to count==39, which is 0.05, but show 0 | ||
| 38 | maximum => App::Chart::Series::Derived::EMA::N_to_alpha(3), | ||
| 39 | parameter_info => [ ], | ||
| 40 | }; | ||
| 41 | |||
| 42 | sub new { | ||
| 43 | my ($class, $parent) = @_; | ||
| 44 | |||
| 45 | return $class->SUPER::new | ||
| 46 | (parent => $parent, | ||
| 47 | parameters => [ ], | ||
| 48 | arrays => { values => [] }, | ||
| 49 | array_aliases => { }); | ||
| 50 | } | ||
| 51 | *warmup_count = \&App::Chart::Series::Derived::MedianAverage::warmup_count; | ||
| 52 | |||
| 53 | sub proc { | ||
| 54 | my ($class) = @_; | ||
| 55 | my $proc_average_and_alpha | ||
| 56 | = App::Chart::Series::Derived::MedianAverage->proc_average_and_alpha; | ||
| 57 | return sub { | ||
| 58 | return ($proc_average_and_alpha->(@_))[1]; | ||
| 59 | }; | ||
| 60 | } | ||
| 61 | |||
| 62 | 1; | ||
| 63 | __END__ |