Class: Indicator::AutoGen::MacdExt
- Defined in:
- lib/indicator/auto_gen/macd_ext.rb
Overview
Ta-Lib function mapping class Function: ‘MACDEXT’ Description: ‘MACD with controllable MA type’ This file has been autogenerated - Do Not Edit.
Instance Attribute Summary collapse
-
#fast_ma ⇒ Object
Fast MA <MA Type>.
-
#fast_period ⇒ Object
Fast Period <Integer>.
-
#signal_ma ⇒ Object
Signal MA <MA Type>.
-
#signal_period ⇒ Object
Signal Period <Integer>.
-
#slow_ma ⇒ Object
Slow MA <MA Type>.
-
#slow_period ⇒ Object
Slow Period <Integer>.
Attributes inherited from Base
Class Method Summary collapse
-
.arguments ⇒ Object
The list of arguments.
-
.inputs ⇒ Object
The minimum set of inputs required.
-
.outputs ⇒ Object
The outputs generated by this function.
-
.price_input? ⇒ Boolean
Is price data required as an input.
Instance Method Summary collapse
-
#initialize(*args) ⇒ MacdExt
constructor
A new instance of MacdExt.
- #run(in_real) ⇒ Object
Methods inherited from Base
Methods included from DataMapper
#default_getter, #default_getter=, #map
Constructor Details
#initialize(*args) ⇒ MacdExt
Returns a new instance of MacdExt.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/indicator/auto_gen/macd_ext.rb', line 19 def initialize(*args) if args.first.is_a? Hash h = args.first @fast_period = h[:fast_period] || 12 @fast_ma = h[:fast_ma] || 0 @slow_period = h[:slow_period] || 26 @slow_ma = h[:slow_ma] || 0 @signal_period = h[:signal_period] || 9 @signal_ma = h[:signal_ma] || 0 else @fast_period = args[0] || 12 @fast_ma = args[1] || 0 @slow_period = args[2] || 26 @slow_ma = args[3] || 0 @signal_period = args[4] || 9 @signal_ma = args[5] || 0 end @func = TaLib::Function.new("MACDEXT") end |
Instance Attribute Details
#fast_ma ⇒ Object
Fast MA <MA Type>
9 10 11 |
# File 'lib/indicator/auto_gen/macd_ext.rb', line 9 def fast_ma @fast_ma end |
#fast_period ⇒ Object
Fast Period <Integer>
7 8 9 |
# File 'lib/indicator/auto_gen/macd_ext.rb', line 7 def fast_period @fast_period end |
#signal_ma ⇒ Object
Signal MA <MA Type>
17 18 19 |
# File 'lib/indicator/auto_gen/macd_ext.rb', line 17 def signal_ma @signal_ma end |
#signal_period ⇒ Object
Signal Period <Integer>
15 16 17 |
# File 'lib/indicator/auto_gen/macd_ext.rb', line 15 def signal_period @signal_period end |
#slow_ma ⇒ Object
Slow MA <MA Type>
13 14 15 |
# File 'lib/indicator/auto_gen/macd_ext.rb', line 13 def slow_ma @slow_ma end |
#slow_period ⇒ Object
Slow Period <Integer>
11 12 13 |
# File 'lib/indicator/auto_gen/macd_ext.rb', line 11 def slow_period @slow_period end |
Class Method Details
.arguments ⇒ Object
The list of arguments
46 47 48 |
# File 'lib/indicator/auto_gen/macd_ext.rb', line 46 def self.arguments [ :fast_period, :fast_ma, :slow_period, :slow_ma, :signal_period, :signal_ma ] end |
.inputs ⇒ Object
The minimum set of inputs required
51 52 53 |
# File 'lib/indicator/auto_gen/macd_ext.rb', line 51 def self.inputs [ :in_real ] end |
.outputs ⇒ Object
The outputs generated by this function
56 57 58 |
# File 'lib/indicator/auto_gen/macd_ext.rb', line 56 def self.outputs [ :out_macd, :out_macd_signal, :out_macd_hist ] end |
.price_input? ⇒ Boolean
Is price data required as an input
41 42 43 |
# File 'lib/indicator/auto_gen/macd_ext.rb', line 41 def self.price_input? false end |
Instance Method Details
#run(in_real) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/indicator/auto_gen/macd_ext.rb', line 60 def run(in_real) len = in_real.length @func.in_real(0, map(in_real)) @func.opt_int(0, @fast_period) @func.opt_int(1, @fast_ma) @func.opt_int(2, @slow_period) @func.opt_int(3, @slow_ma) @func.opt_int(4, @signal_period) @func.opt_int(5, @signal_ma) out_macd = Array.new(len) @func.out_real(0, out_macd) out_macd_signal = Array.new(len) @func.out_real(1, out_macd_signal) out_macd_hist = Array.new(len) @func.out_real(2, out_macd_hist) @func.call(0, len - 1) {:out_macd => out_macd, :out_macd_signal => out_macd_signal, :out_macd_hist => out_macd_hist} end |