# Ta-Lib function mapping class 
# Function: 'ULTOSC'
# Description: 'Ultimate Oscillator'
# This file has been autogenerated - Do Not Edit.
class Indicator::AutoGen::UltOsc < Indicator::Base
  # First Period <Integer>
  attr_accessor :first_period
  # Second Period <Integer>
  attr_accessor :second_period
  # Third Period <Integer>
  attr_accessor :third_period

  def initialize(*args)
    if args.first.is_a? Hash
      h = args.first
      @first_period = h[:first_period] || 7
      @second_period = h[:second_period] || 14
      @third_period = h[:third_period] || 28
    else
      @first_period = args[0] || 7 
      @second_period = args[1] || 14 
      @third_period = args[2] || 28 
    end
    
    @func = TaLib::Function.new("ULTOSC")
  end

  # Is price data required as an input
  def self.price_input?
    true
  end

  # The list of arguments
  def self.arguments
    [ :first_period, :second_period, :third_period ]
  end

  # The minimum set of inputs required
  def self.inputs
    [ :high, :low, :close ]
  end

  # The outputs generated by this function
  def self.outputs
    [ :out_real ]
  end

  def run(*args)
    o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
    @func.in_price(0, o, h, l, c, v, nil)

    @func.opt_int(0, @first_period)
    @func.opt_int(1, @second_period)
    @func.opt_int(2, @third_period)

    out_real = Array.new(len)
    @func.out_real(0, out_real)
  
    @func.call(0, len - 1)

    out_real
  end
end
