Applying the Math
The stock market is just math with emotion attached. Strip the emotion away and what's left are patterns — and patterns are exactly what algorithms are built to find.
Start Simple
The most basic way to understand an algorithm applied to stocks is a price rising in a straight line. Using simple geometry you can predict what the price will be at a future date.
Just plot the equation for a triangle and you can tell the date and the price to sell your stock — or to buy it. mx + b is the equation. Or if you prefer: a² + b² = c².
That's not Wall Street magic. That's geometry you learned in school. The only difference is applying it to a chart instead of a textbook problem.
mx + b — price rising at a steady rate.
Plot two known points, extrapolate to the future.
Reading Patterns
Head & Shoulders pattern — real price movement
is never a straight line. That's where segments come in.
The Head and Shoulders pattern is one of the most well-known in stock charting. A left shoulder, a higher peak (the head), a right shoulder — and then a drop. Recognizing these patterns is exactly what an algorithm is designed to do.
The straight line algorithm works for some stocks some of the time. But a more realistic chart looks like the one on the left — the same movement broken into multiple segments.
Each segment is its own straight line. String enough of them together and you get a curve. That curve is your algorithm finding its real shape.
Common Patterns
These are the basic shapes that repeat in stock charts. Once you can see them, you can start building variables that detect them.
Price rising consistently over time. The simplest algorithm — mx+b. Predictable, reliable, but rarely lasts forever.
Peaks and valleys with a dominant high in the middle. Each segment is a separate calculation. Stack them and you see the full picture.
Price bouncing between a floor and a ceiling. Your algorithm needs to identify the boundaries — that's where buy and sell signals live.
The Key Insight
The chart with curved lines seems complicated — but all it really is are the same straight line charts, just with smaller and smaller segments. The math for the algorithm would look something like this:
Sum of price + time variables divided by your baseline
Which looks complicated for the average person. But when you break it down and do only one segment at a time it becomes much clearer and infinitely more simple.
The more points you use, the smoother the line — more curvaceous, more accurate. The more straight line segments, the less predictable. More data = better algorithm. That's the whole game.
A model built on 3 data points gives you a rough shape. It'll get the direction right but miss the detail. Good enough to start, not enough to rely on.
64 variables, 100 data points, multiple time periods — the curve gets smoother and the predictions get tighter. This is why data matters.
Every chart has a question mark at the end — the future price. Your algorithm's entire job is to make that question mark as small as possible.
Run your model across many historical points first. Find the pattern. Only then extrapolate forward. Prediction without pattern is just guessing.