One of the ways: sma_up = sma1(0) > sma1(-1) sma_dn = sma1(0) < sma1(-1)