now get_rate
This commit is contained in:
parent
b065a548da
commit
be5f2458fa
@ -1,48 +0,0 @@
|
||||
function get_fibonacci_indicator {
|
||||
#g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
|
||||
# get histfile
|
||||
local f_hist_file="$1"
|
||||
local f_period="$2"
|
||||
|
||||
f_fibonacci=""
|
||||
|
||||
# Check for enough time periods in data
|
||||
local f_period=$((f_period+1))
|
||||
local f_period_sum=$(tail -n${f_period} "${f_hist_file}" | cut -d, -f2 | grep "^[0-9]" | wc -l)
|
||||
if ! [ ${f_period_sum} -ge ${f_period} ]
|
||||
then
|
||||
g_echo_note "${FUNCNAME} $@: Not enough data - waiting for more values and defaulting to 0. (${f_period} needed; ${f_period_sum} given)"
|
||||
echo -n ",0" >>"${f_hist_file}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# get highest and lowest price in period and current price
|
||||
local f_highest=$(tail -n${f_period} "${f_hist_file}" | cut -d"," -f2 | grep "^[0-9]" | sort -n | tail -n1)
|
||||
local f_lowest=$(tail -n${f_period} "${f_hist_file}" | cut -d"," -f2 | grep "^[0-9]" | sort -n | head -n1)
|
||||
local f_price=$(tail -n1 "${f_hist_file}" | cut -d"," -f2 | grep "^[0-9]")
|
||||
# calculate range
|
||||
local f_range=$(echo "${f_highest}-${f_lowest}" | bc -l)
|
||||
|
||||
# calculate current difference to highest
|
||||
local f_diff_to_highest=$(echo "${f_highest}-${f_price}" | bc -l)
|
||||
local f_diff_to_highest_in_range=$(echo "${f_range}-${f_diff_to_highest}" | bc -l)
|
||||
|
||||
# calculate fibonacci retracement value from range to difference of highest price
|
||||
f_fibonacci=$(echo "scale=8; 1+(1/${f_range}*(${f_diff_to_highest_in_range}-${f_range}))" | bc | sed 's/^\./0./;' | xargs printf "%.3f")
|
||||
#f_fibonacci=$(g_percentage-diff ${f_range} ${f_diff_to_highest_in_range})
|
||||
|
||||
echo -n ",${f_fibonacci}" >>"${f_hist_file}"
|
||||
|
||||
# echo "
|
||||
#Highest=$f_highest
|
||||
#Lowest=$f_lowest
|
||||
#Price=$f_price
|
||||
#Range=$f_range
|
||||
#highest-diff=$f_diff_to_highest
|
||||
#highest-diff-range=$f_diff_to_highest_in_range
|
||||
#"
|
||||
|
||||
#g_echo_note "Fibonacci-Retracement: ${f_fibonacci}"
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user