Our exponential moving average calculation is calculated on every tick increment over our time series. Again, we'll employ the reduce
function to fold up the previous 20 ticks, into an average value. In order to do this, though, we'll need to dig into the source data for the SMA.
If you recall from Chapter 2, First Principles and a Useful Way to Think, our prices were a list of maps that looked like the following piece of code. We put the price in a map to communicate the fact that it was the last or most recent price being calculated:
{:last 16.68101235523256}
Our final time series was a list of maps that looked like the following:
{:last-trade-price {:last 5.466160487301605}, :last-trade-time #inst "2015-09-24T04:13:13.868-00:00"}
This means that our price lists aren't just carrying around prices. They're carrying around price and time values. Now we'll add our calculated average to the stuff carried around. You'll often find the need to carry around essential...