shell script | bc syntax format

sorry but need help

trying to achieve ema
in script I have this syntax which errors

ema=[`"$(echo (${currentprice} * 0.153846154) + (${previousema} * {1 - 0.153846154}) | bc)" -q 1 ]` ;

the 0.153846154 ='s Smoothing Factor

really appreciate help

This may help

ema=`echo "(${currentprice} * 0.153846154) + (${previousema} * (1 - 0.153846154))" | bc`
1 Like

You are mixing more than one command.

ema=$(echo "($currentprice*0.153846154)+($previousema*(1-0.153846154))" | bc) 

if [ "$ema" -eq 1 ]; then
 echo do something
fi
1 Like

nice guys thanks