Sha256: 274f7f3a1fcb517689230466324e8bed9570edee89aa177f2680fb7f9e548c5b

Contents?: true

Size: 874 Bytes

Versions: 21

Compression:

Stored size: 874 Bytes

Contents

# lib/sqa/indicator/market_profile.rb

class SQA::Indicator; class << self

  def market_profile(
        volumes,              # Array of volumes
        prices,               # Array of prices
        support_threshold,    # Float stock's support price estimate
        resistance_threshold  # Float stock's resistance price estimate
      )
    total_volume    = volumes.sum
    average_volume  = volumes.mean
    max_volume      = volumes.max

    support_levels    = prices.select { |price| price <= support_threshold }
    resistance_levels = prices.select { |price| price >= resistance_threshold }

    if  support_levels.empty?     &&
        resistance_levels.empty?
      :neutral
    elsif support_levels.empty?
      :resistance
    elsif resistance_levels.empty?
      :support
    else
      :mixed
    end
  end
  alias_method :mp, :market_profile

end; end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
sqa-0.0.24 lib/sqa/indicator/market_profile.rb
sqa-0.0.22 lib/sqa/indicator/market_profile.rb
sqa-0.0.21 lib/sqa/indicator/market_profile.rb
sqa-0.0.20 lib/sqa/indicator/market_profile.rb
sqa-0.0.19 lib/sqa/indicator/market_profile.rb
sqa-0.0.18 lib/sqa/indicator/market_profile.rb
sqa-0.0.17 lib/sqa/indicator/market_profile.rb
sqa-0.0.15 lib/sqa/indicator/market_profile.rb
sqa-0.0.14 lib/sqa/indicator/market_profile.rb
sqa-0.0.13 lib/sqa/indicator/market_profile.rb
sqa-0.0.12 lib/sqa/indicator/market_profile.rb
sqa-0.0.11 lib/sqa/indicator/market_profile.rb
sqa-0.0.10 lib/sqa/indicator/market_profile.rb
sqa-0.0.9 lib/sqa/indicator/market_profile.rb
sqa-0.0.8 lib/sqa/indicator/market_profile.rb
sqa-0.0.7 lib/sqa/indicator/market_profile.rb
sqa-0.0.6 lib/sqa/indicator/market_profile.rb
sqa-0.0.5 lib/sqa/indicator/market_profile.rb
sqa-0.0.4 lib/sqa/indicator/market_profile.rb
sqa-0.0.3 lib/sqa/indicator/market_profile.rb