From fe591c169f736fd9172b583115c3daebb7efc243 Mon Sep 17 00:00:00 2001 From: olli Date: Mon, 15 May 2023 16:43:35 +0200 Subject: [PATCH] force minimum 15 minutes (900 seconds) timeframe foor EMA/MACD calculations --- dabo/functions/get_macd_indicator.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dabo/functions/get_macd_indicator.sh b/dabo/functions/get_macd_indicator.sh index ff1463a..046f78b 100644 --- a/dabo/functions/get_macd_indicator.sh +++ b/dabo/functions/get_macd_indicator.sh @@ -19,7 +19,10 @@ function get_macd_indicator { # read last two lines local f_lastline=$(tail -n1 "$f_hist_file" | grep ^2) - local f_second_lastline=$(tail -n2 "$f_hist_file" | head -n1 | grep ^2) + + # force min 15min 2 last lines + local f_last_macd_period=$(echo "2*(900/${INTERVAL})" | bc -l | sed 's/\..*//') + local f_second_lastline=$(tail -n${f_last_macd_period} "$f_hist_file" | head -n1 | grep ^2) # Try to get current MACD values local f_macd_lastprice=$(echo "$f_lastline" | cut -d, -f2)