| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright 2006, 2007, 2009, 2010, 2011 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::FRAMAalpha; |
|
18
|
1
|
|
|
1
|
|
20938
|
use 5.010; |
|
|
1
|
|
|
|
|
3
|
|
|
19
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
19
|
|
|
|
1
|
|
|
|
|
20
|
|
|
20
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
21
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
53
|
|
|
22
|
1
|
|
|
1
|
|
5
|
use List::Util qw(min max); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
77
|
|
|
23
|
1
|
|
|
1
|
|
14
|
use Locale::TextDomain ('App-Chart'); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
177
|
use base 'App::Chart::Series::Indicator'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
300
|
|
|
26
|
|
|
|
|
|
|
use App::Chart::Series::Derived::FRAMAdimension; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub longname { __('FRAMA - Alpha') } |
|
30
|
|
|
|
|
|
|
sub shortname { __('FRAMA alpha') } |
|
31
|
|
|
|
|
|
|
sub manual { __p('manual-node','Fractal Adaptive Moving Average') } |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use constant |
|
34
|
|
|
|
|
|
|
{ type => 'indicator', |
|
35
|
|
|
|
|
|
|
priority => -10, |
|
36
|
|
|
|
|
|
|
units => 'ema_alpha', |
|
37
|
|
|
|
|
|
|
# actually the minimum is 0.01 below, but show 0 |
|
38
|
|
|
|
|
|
|
minimum => 0, |
|
39
|
|
|
|
|
|
|
maximum => 1, |
|
40
|
|
|
|
|
|
|
parameter_info => |
|
41
|
|
|
|
|
|
|
App::Chart::Series::Derived::FRAMAdimension::parameter_info(), |
|
42
|
|
|
|
|
|
|
}; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new { |
|
45
|
|
|
|
|
|
|
my ($class, $parent, $N) = @_; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$N //= parameter_info()->[0]->{'default'}; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
return $class->SUPER::new |
|
50
|
|
|
|
|
|
|
(parent => $parent, |
|
51
|
|
|
|
|
|
|
parameters => [ $N ], |
|
52
|
|
|
|
|
|
|
arrays => { values => [] }, |
|
53
|
|
|
|
|
|
|
array_aliases => { }); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
*warmup_count = \&App::Chart::Series::Derived::FRAMAdimension::warmup_count; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub proc { |
|
58
|
|
|
|
|
|
|
my ($class, $N) = @_; |
|
59
|
|
|
|
|
|
|
my $dim_proc = App::Chart::Series::Derived::FRAMAdimension->proc($N); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return sub { |
|
62
|
|
|
|
|
|
|
my $dim = $dim_proc->(@_) // return undef; |
|
63
|
|
|
|
|
|
|
return max(0.01, min(1.0, exp(-4.6*($dim-1)))); |
|
64
|
|
|
|
|
|
|
}; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
*fill_part = \&App::Chart::Series::Derived::WilliamsR::fill_part; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
|
69
|
|
|
|
|
|
|
__END__ |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# =head1 NAME |
|
72
|
|
|
|
|
|
|
# |
|
73
|
|
|
|
|
|
|
# App::Chart::Series::Derived::FRAMAalpha -- alpha for fractal adaptive moving average |
|
74
|
|
|
|
|
|
|
# |
|
75
|
|
|
|
|
|
|
# =head1 SYNOPSIS |
|
76
|
|
|
|
|
|
|
# |
|
77
|
|
|
|
|
|
|
# my $series = $parent->FRAMAalpha($N); |
|
78
|
|
|
|
|
|
|
# |
|
79
|
|
|
|
|
|
|
# =head1 DESCRIPTION |
|
80
|
|
|
|
|
|
|
# |
|
81
|
|
|
|
|
|
|
# ... |
|
82
|
|
|
|
|
|
|
# |
|
83
|
|
|
|
|
|
|
# =head1 SEE ALSO |
|
84
|
|
|
|
|
|
|
# |
|
85
|
|
|
|
|
|
|
# L<App::Chart::Series> |
|
86
|
|
|
|
|
|
|
# |
|
87
|
|
|
|
|
|
|
# =cut |