Research project · Field study

How trading algorithms process data and decide to act.

An independent study by Aditya Singh on simple quantitative trading rules: moving averages, RSI, and the software path from a price file to a buy or sell mark.

160

illustrative days

3

rules compared

t + 1

fill delay

19%

of days long

01

Foundations

Math I used: averages, RSI, returns, and a little volatility.

Open
02

Architecture

How a program reads bars, computes a signal, and logs a decision.

Open
03

Findings

An illustrative SMA test, a small metrics table, and what I conclude.

Open

Abstract

I wanted to see how a trading program turns a list of prices into a decision. I coded a simple moving average, a 20/50 crossover, and RSI-14, and I forced the program to wait until the next day to act.

The charts use one constructed 160-day path so I could show a dip without pretending I have a live record. On that path, buy-and-hold returned −6.5% and fell −10.4% from its peak. A 50-day long/cash rule was in the market on 19% of the days after warmup, returned −3.3%, and fell −4.3%. A 20/50 crossover returned −1.1% and flipped 4 times. I am not ranking these rules. I am showing the machine: a window of closes, a comparison, a one-day wait, and a chart of the damage.

Research question

I am a Computer Engineering student. In my free time I started reading about quantitative finance, which is the idea of using math and code to look at market data instead of guessing from headlines. Sites like Quantpedia collect many of these rules in one place (Quantpedia, n.d.). I wanted to understand, at a beginner level, how a program actually turns a list of prices into a decision.

The question I am working with is: if I only use public daily prices, can a few old formulas — a simple moving average and the Relative Strength Index — produce a rule I can code, check, and explain? I am not trying to invent a hedge-fund strategy. I am trying to walk through the same building blocks that show up in textbooks and in catalogs of published rules (Brock, Lakonishok, and LeBaron, 1992; Faber, 2007).

The work is split the way a small study is usually split. Foundations is the math. Architecture is the software. Findings is what happened when I ran a long/cash moving-average rule on an illustrative price path, and what I am willing to conclude from that. All of the charts on this site are built from that same generated series so the pictures match the formulas.

How to read this notebook

If you only have a few minutes: start at Foundations for the equations, skim the four-stage pipeline on Architecture, then read the conclusion on Findings. About me is who I am and the claims I am not making. Nothing here is a live track record. The series is constructed so I can show a crash, a bounce, and a whipsaw on one screen.

Copy on these pages is kicked slightly opposite the scroll, then springs back. That is the same delay a moving average has versus price.

SMA-50 stays fixed. Drag to see how a faster average hugs price.

Figure 1. Illustrative close price with a 20-day SMA (teal) and a 50-day SMA (grey). Drag the fast window if you want to see the lag change. The slow line still lags the drop in the middle — that delay is the whole point of a moving average.
New York Stock Exchange facade
Figure 2. The New York Stock Exchange. Daily prices used in this kind of study come from exchanges like this, then get packaged into CSV files students can download. Photo: The Wall Street Experience blog.

What I concluded

Three things survived the test. The full argument, the table, and the limits sit on Findings. This is the short version.

  1. 01

    A decision is a function

    Window of closes, a comparison, a clock. If the clock is wrong, the study is fiction.

  2. 02

    This path ends down

    Buy-and-hold lost −6.5%. Cash helped any rule that sat out part of the dip. That is a property of the sample, not a ranking of averages.

  3. 03

    No edge claimed

    I can show a pipeline. I cannot show that these lines beat a market that pays rent.

Sources

  1. Quantpedia. Encyclopedia of Quantitative Trading Strategies.
  2. Brock, W., Lakonishok, J., & LeBaron, B. (1992). Simple technical trading rules and the stochastic properties of stock returns. Journal of Finance.
  3. Faber, M. (2007). A quantitative approach to tactical asset allocation. Journal of Wealth Management.