Profitable $tock trading models and Jupyter notebook

gk_
7 min readOct 23, 2019

Stock trading models can look enticing, testing them against historical data often reveals a less promising reality. And sometimes the output of a model is itself material for a model with curious correlation to actual data.

An article about a stock trading model caught my attention several months ago and while at first it seemed inconsequential, over time it began to bother me. Why? Because its signals were producing interesting results.

The model described used 2 trend-lines: the Exponential Moving Average (EMA) and Bollinger Bands (BB), as a stock’s closing price moves these lines shift and when they cross a signal is generated to either buy Long or sell Short. The model was applied to ETFs, A stock ETF, or exchange-traded fund, is an asset that tracks a particular set of equities, similar to an index.

One interesting aspect of an ETF, for example the Nasdaq’s QQQ, is one can sell it short by buying a derivative ETF rather than actually shorting QQQ, which is a more complex trade. You can purchase shares in SQQQ and gain from downward movement in the index. This makes shorting quite simple.

Below is the upward movement in QQQ from early June (see bottom bar) to end of July following a crossing of these trend-lines. A gain of over 5% if one bought the day of the upward…

--

--