Signals using moving averages

Now that our analytic functions are lazy and we can join them into one list, we can start thinking about what signals we may be interested in. A simple and direct signal is finding out whether the EMA in one tick element has crossed above the SMA from a previous element. Another signal would be the inverse of this—we can find out whether, in the first element, the EMA has crossed below the SMA from the second element. This is another process criteria where a current tick needs to know about a previous tick. However, in this situation, the previous computation isn't needed by the current one. We can just partition our ticks by two to check for a crossover. Let's take a look at an implementation now:

(defn moving-averages-signals ...

Get Clojure for Finance now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.