The algorithm we will work with for the rest of the chapter is called simple moving average (SMA). It's a very well-known tool for doing technical analysis of time-series, specially for financial markets and trading. The idea behind SMA is that you will compute an average at each point in time by looking back at a predefined number periods. For example, let's say you're looking at a minute-by-minute time-series, and you will compute an SMA(30). This means that at each observation in your time-series, you will take the observations that correspond to the previous 30 minutes from starting at a specific observation (30 observations back), and will save the average for those 30 observations as the SMA(30) value for that point in time.
In the later diagram, you can visualize the idea behind SMAs. The diagram shows a monotone...