diff --git a/dabo/functions/check_buy_conditions.sh b/dabo/functions/check_buy_conditions.sh index 4e5ef48..b3f75c6 100644 --- a/dabo/functions/check_buy_conditions.sh +++ b/dabo/functions/check_buy_conditions.sh @@ -31,7 +31,7 @@ function check_buy_conditions { if check_buy_conditions_strategy ${f_ASSET_HIST_FILE} ${f_strategy} then f_BUY="${f_echo_prefix} All BUY conditions met!!! -${f_last_line},${f_market_performance}" +${f_last_line}" break fi done @@ -123,7 +123,7 @@ function check_buy_conditions_strategy { # Check market-performance if [ $(echo "${f_market_performance} > ${GOOD_MARKET_PERFORMANCE_INDEX}" | bc -l) -eq 0 ] then - echo " --> ${f_echo_prefix}BUY market performance ${f_market_performance}% looks bad - Dont buy anything" + echo " ${f_echo_prefix}BUY market performance ${f_market_performance}% looks bad - Dont buy anything" return 1 fi @@ -132,19 +132,19 @@ function check_buy_conditions_strategy { local f_pricediff=$(g_percentage-diff "$f_priceXago" "$f_pricenow") if [ $(echo "${f_pricediff} < ${BUY_MINGROWTH}" | bc -l) -ne 0 ] then - echo " --> ${f_echo_prefix}With ${f_pricediff} under ${BUY_MINGROWTH}% growth in the last ${BUY_MINGROWTH_PERIOD} time periods" + echo " ${f_echo_prefix}With ${f_pricediff} under ${BUY_MINGROWTH}% growth in the last ${BUY_MINGROWTH_PERIOD} time periods" return 1 fi # Check MACD if [ $(echo "${f_macd_histogram_relation} < ${BUY_MACD_RELATION_FROM}" | bc -l) -ne 0 ] then - echo " --> ${f_echo_prefix}MACD Relation with ${f_macd_histogram_relation}% under BUY_MACD_RELATION_FROM ${BUY_MACD_RELATION_FROM}%" + echo " ${f_echo_prefix}MACD Relation with ${f_macd_histogram_relation}% under BUY_MACD_RELATION_FROM ${BUY_MACD_RELATION_FROM}%" return 1 fi if [ $(echo "${f_macd_histogram_relation} > ${BUY_MACD_RELATION_TO}" | bc -l) -ne 0 ] then - echo " --> ${f_echo_prefix}MACD Relation with ${f_macd_histogram_relation}% over BUY_MACD_RELATION_TO ${BUY_MACD_RELATION_TO}%" + echo " ${f_echo_prefix}MACD Relation with ${f_macd_histogram_relation}% over BUY_MACD_RELATION_TO ${BUY_MACD_RELATION_TO}%" return 1 fi @@ -169,7 +169,7 @@ function check_buy_conditions_strategy { then echo "${f_echo_prefix}RSI conditions met" >/dev/null else - echo " --> ${f_echo_prefix}RSI conditions NOT met" + echo " ${f_echo_prefix}RSI conditions NOT met" return 1 fi @@ -182,9 +182,40 @@ function check_buy_conditions_strategy { then echo "${f_echo_prefix}Price change conditions met" >/dev/null else - echo " --> ${f_echo_prefix}Price change conditions NOT met" + echo " ${f_echo_prefix}Price change conditions NOT met" return 1 fi + + # after high change in one period next price often falls + if [ -n "${BUY_DONT_WHEN_LAST_RATE_HIGHER_THEN}" ] + then + if [ $(echo "${f_price_change} > ${BUY_DONT_WHEN_LAST_RATE_HIGHER_THEN}" | bc -l) -ne 0 ] + then + echo " ${f_echo_prefix}BUY_DONT_WHEN_LAST_RATE_HIGHER_THEN (${BUY_DONT_WHEN_LAST_RATE_HIGHER_THEN}) met" + return 1 + fi + fi + + if [ -n "${BUY_DONT_WHEN_LAST_RATE_LOWER_THEN}" ] + then + if [ $(echo "${f_price_change} < ${BUY_DONT_WHEN_LAST_RATE_LOWER_THEN}" | bc -l) -ne 0 ] + then + echo " ${f_echo_prefix}BUY_DONT_WHEN_LAST_RATE_LOWER_THEN (${BUY_DONT_WHEN_LAST_RATE_LOWER_THEN}) met" + return 1 + fi + fi + + + # dont buy on negative last result + if [ "${BUY_DONT_WHEN_LAST_RATE_NEGATIVE}" = true ] + then + if echo "${f_price_change}" | grep -q "^-" + then + echo " ${f_echo_prefix}BUY_DONT_WHEN_LAST_RATE_NEGATIVE met" + return 1 + fi + fi + } diff --git a/dabo/functions/check_sell_conditions.sh b/dabo/functions/check_sell_conditions.sh index 1b82b09..508e59b 100644 --- a/dabo/functions/check_sell_conditions.sh +++ b/dabo/functions/check_sell_conditions.sh @@ -201,7 +201,7 @@ function check_sell_conditions_strategy { then if [ $(echo "(${f_BUY_PRICE_LAST_RATE_DIFF} + -${FEE}) < 0" | bc -l) -ne 0 ] then - echo " --> Result negative - holding (INTERIM RESULT ${f_BUY_PRICE_LAST_RATE_DIFF}% - FEE ${FEE}% < 0" + echo " Result negative - holding (INTERIM RESULT ${f_BUY_PRICE_LAST_RATE_DIFF}% - FEE ${FEE}% < 0" f_SELL="" fi fi