From 8dd70423d1494c1b6d9e3892e942303f5ac720ba Mon Sep 17 00:00:00 2001 From: shogochiai Date: Fri, 30 Jun 2017 04:09:04 +0000 Subject: [PATCH 1/3] add vendor directory to gitignroe --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a955cfa..d136bb7 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ test/tmp test/version_tmp tmp .DS_Store +vendor From d03a244b97aea28a864bac28268bb9a59b27c16e Mon Sep 17 00:00:00 2001 From: shogochiai Date: Fri, 30 Jun 2017 16:05:33 +0000 Subject: [PATCH 2/3] active_support error workaround --- lib/indicators.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/indicators.rb b/lib/indicators.rb index 4d6e1c0..169af19 100644 --- a/lib/indicators.rb +++ b/lib/indicators.rb @@ -1,3 +1,4 @@ +require 'active_support' require "indicators/version" require "securities" require "indicators/data.rb" From b2f9db2754077a24123857d6c1dfb42fba6df584 Mon Sep 17 00:00:00 2001 From: shogochiai Date: Fri, 30 Jun 2017 17:28:17 +0000 Subject: [PATCH 3/3] prototype of psar --- lib/indicators/calculations/psar.rb | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 lib/indicators/calculations/psar.rb diff --git a/lib/indicators/calculations/psar.rb b/lib/indicators/calculations/psar.rb new file mode 100644 index 0000000..37571b4 --- /dev/null +++ b/lib/indicators/calculations/psar.rb @@ -0,0 +1,69 @@ +# Parabolic Stop-and-Reversal +# http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:parabolic_sar +# +# ------------------------------ +# +# [Rising SAR] +# +# Prior SAR: The SAR value for the previous period. +# +# Extreme Point (EP): The highest high of the current uptrend. +# +# Acceleration Factor (AF): +# Starting at .02, AF increases by .02 each +# time the extreme point makes a new high. AF can reach a maximum +# of .20, no matter how long the uptrend extends. +# +# Current SAR = Prior SAR + Prior AF(Prior EP - Prior SAR) +# = 48.13 + .14(49.20 - 48.13) +# = 48.28 +# +# The Acceleration Factor is multiplied by the difference between the +# Extreme Point and the prior period's SAR. This is then added to the +# prior period's SAR. Note however that SAR can never be above the +# prior two periods' lows. Should SAR be above one of those lows, use +# the lowest of the two for SAR. +# +# ------------------------------ +# +# [Falling SAR] +# +# Prior SAR: The SAR value for the previous period. +# +# Extreme Point (EP): The lowest low of the current downtrend. +# +# Acceleration Factor (AF): +# Starting at .02, AF increases by .02 each +# time the extreme point makes a new low. AF can reach a maximum +# of .20, no matter how long the downtrend extends. +# +# Current SAR = Prior SAR - Prior AF(Prior SAR - Prior EP) +# = 43.84 - .16(43.84 - 42.07) +# = 43.56 +# +# The Acceleration Factor is multiplied by the difference between the +# Prior period's SAR and the Extreme Point. This is then subtracted +# from the prior period's SAR. Note however that SAR can never be +# below the prior two periods' highs. Should SAR be below one of +# those highs, use the highest of the two for SAR. +# +# ------------------------------ + +module Indicators + class Psar + # Input + # Returns [] + def self.calculate data, parameters + output = Array.new + # initialize SAR + # subscription start + # new trade coming + # define rising_faling_flag by diff + # if condition rising_faling_flag + # Use "+ Prior AF(Prior EP - Prior SAR)" or "- Prior AF(Prior SAR - Prior EP)" + + return output + end + + end +end \ No newline at end of file