algorithmic-trading · Lesson 6

Where AI & Machine Learning Fit

What machine learning really does in trading — and why markets fight it harder than almost any other problem a computer is asked to solve.

6 min readIntermediateSean ShaReviewed by Sean ShaUpdated: July 2026
Where AI & Machine Learning Fit — illustration of a friendly kitchen scene where one person shows a recipe card with written steps

Educational purposes only. This content does not constitute investment advice. Read our disclaimer

StockCram is not a broker-dealer, investment adviser, or financial institution. All content is for educational and informational purposes only and should not be construed as personalized investment advice. Consult a qualified financial professional before making investment decisions. Past performance does not guarantee future results.

TL;DR

In a rules-based algorithm, a human writes the signal formula by hand. In a machine-learning approach, the human instead feeds the software many labeled examples and lets it learn a pattern — much like a spam filter trained on emails marked spam or not-spam. In the simplified architecture this course uses, the model most often lives in one box — the signal engine, where it outputs a score, not a trade — though more advanced systems also apply machine learning to execution, order routing, and risk monitoring. Markets are an unusually hostile place for this, because prices are mostly noise, the patterns keep shifting, and any edge that's found and traded tends to erase itself. Machine learning is a pattern-finder, not a money printer — which makes the risk checks from earlier lessons matter more, not less.

Two Ways to Write the Same Signal

Back in the anatomy lesson we drew a deliberately simplifying line: in the basic architecture this course uses, machine learning most often lives in one box — the signal engine — where it produces a score, never a trade. (More advanced systems also put machine learning to work elsewhere — in execution and order routing, transaction-cost and market-impact estimation, and risk monitoring — but the signal engine is where it most visibly earns its reputation, so it's the box we open here.) There are two ways to fill that box, and the difference is entirely about who writes the pattern.

In a rules-based algorithm, a person writes the formula by hand: "score a stock +0.8 if it's cheap relative to its average." In a machine-learning approach, the person writes no formula at all. Instead they hand the software thousands of past examples, each labeled with what happened next, and let it learn the pattern on its own. The classic everyday version is a spam filter: nobody writes a rule listing every spammy word — you just show it a pile of emails marked "spam" or "not-spam," and it works out the giveaways itself. A trading model does the same trick on market data. Crucially, the output is identical to the hand-written version — a score. The model is a pattern-finder, not a decision-maker.

So the two approaches fill the same slot in different ways. Here's how they line up on the things that actually matter:

AspectRules-based signalMachine-learning signal
Who writes the logicA person writes the formula by handA person feeds examples; the software learns the formula
What it needsA clear idea and a few parametersLots of labeled historical examples and computing power
Main failure modeThe idea itself is simply wrongOverfitting — memorizing noise that won't repeat
How you'd check itBacktest, then test on data it never sawThe same — plus a strict split it was never trained on

Same signal-engine slot, two ways to fill it. Notice the bottom two rows barely change — both approaches live or die on whether they hold up on data they've never seen.

That last row is the quiet punchline: swapping a human formula for a learned one doesn't change the test that matters. Both have to prove themselves on fresh data. To see why the learned version is especially easy to fool, we first need the handful of words machine-learning people actually use.

The Words Behind Machine Learning

Four terms cover almost everything, and each has a plain-English meaning:

How AI learns a trading signal: feed a model labeled history, it learns a pattern and outputs a score, not a trade, then test on unseen data. Noisy, shifting, data-scarce markets make overfitting easy.
Machine learning fills the signal engine by learning a pattern from labeled examples rather than a hand-written formula, yet still only outputs a score. Noisy, shifting, scarce-data markets make overfitting easy.
  • Features — the inputs, the clues. For a stock these might be recent returns, volume, how far the price sits from its average, or a sentiment score pulled from news. Choosing good features is most of the work.
  • Training — the learning step. The model looks at many historical examples, each paired with what happened next, and adjusts itself to fit that history as well as it can.
  • Prediction (or inference) — using the trained model on new data it hasn't seen, to produce a fresh score.
  • Train/test split — deliberately hiding some of the history. You train on one slice and check the model on a different slice it never touched. Judging a model on the same data it learned from is like grading a student on the exact questions they were given the answers to.

That last idea is the whole ballgame, and it connects straight to last lesson's villain. A model with enough freedom can memorize the training history perfectly — every wiggle, including the pure luck — and look brilliant. Then it meets fresh data and falls apart. That's overfitting, and the train/test split is the main tool for catching it before real money is involved.

Why Markets Fight Machine Learning

Machine learning does genuinely well on problems like reading handwriting or filtering spam. Markets are a much harder arena — arguably one of the hardest there is — for four honest reasons:

  • Terrible signal-to-noise. A photo of a cat is almost entirely signal. A price chart is mostly randomness with a faint pattern buried inside — if one is there at all. The model spends most of its effort trying not to mistake noise for meaning.
  • Non-stationarity. In most machine-learning problems the rules stay put: a cat looks like a cat every year. Markets don't sit still — conditions, participants, and behavior all shift, so a pattern that held for years can quietly decay and stop working.
  • Reflexivity and competition. If a real edge exists and enough people trade it, their own buying and selling can move prices until the edge disappears. The act of using a pattern can erase it — a problem a handwriting reader never faces.
  • Tiny data. Twenty years of daily prices is only about 5,000 data points. To a field that trains on millions of images, that's a scrap. Small data plus a flexible model is the perfect recipe for overfitting.

Why this combination is dangerous

Each of those four on its own makes finding a durable edge hard. Together they make it very easy to believe you've found one that isn't real. A flexible model, pointed at noisy, shifting, scarce data, will almost always discover a beautiful pattern in the training set — and that pattern is often just memorized luck. This is why serious quant teams treat an impressive backtest with suspicion, not excitement.

What AI Genuinely Helps With

None of that means machine learning is useless here — it means the honest use is narrower than the headlines suggest. Where it earns its keep is on jobs that play to its real strength, which is chewing through more information than a person can:

  • Sifting huge, messy inputs — turning piles of news text, filings, or other unstructured data into a tidy number a strategy can use.
  • Spotting non-obvious combinations — weighing dozens of features at once to notice interactions a human might not think to write into a formula by hand.
  • Automating research — testing many candidate ideas quickly, so people spend their time on the promising few instead of the drudgery.

In every one of these, the model is a tool that proposes a signal. A human still has to validate it on unseen data, decide whether it makes sense, and wrap it in the risk checks from earlier lessons. AI widens the funnel of ideas; it doesn't remove the need for judgment at the end of it. And the signal engine isn't the only place it turns up: in the simplified architecture used throughout this course, AI most commonly appears there, but more advanced systems also apply machine learning to execution, order routing, transaction-cost and market-impact estimation, risk monitoring, and anomaly detection. The same honest caveats — noise, shifting patterns, and the need for out-of-sample checks — follow it into each of those jobs.

Same Slot, a Different Score

Make it concrete. A hand-written signal might be one line: "score +1 to buy if the price is above its 200-day moving average, otherwise 0." One clue, one rule, written by a person in an afternoon. A machine-learning version of the same slot says instead: "here are 20 years of examples, each tagged with whether the next month was up or down, and 50 possible clues — you figure out how to weigh them into a score."

Both drop a number into the exact same signal-engine box, and both feed the identical rules, risk checks, and execution downstream. The difference is only in how the score is produced — one from a formula a human chose, one from a pattern the software learned. And both face the same final exam: does the score still work on data the system has never seen? If the answer isn't a confident yes, the extra machinery of the learned version bought nothing but a more convincing way to fool yourself.

The Honest Bottom Line

Machine learning is a tool for finding patterns, not a machine that prints money. When a model you don't fully understand is generating the signal, the discipline from earlier lessons — out-of-sample testing, position limits, drawdown caps, a kill switch — matters more, not less, because you can no longer eyeball the logic and sanity-check it in your head. A learned signal deserves more suspicion than a hand-written one, not a pass because it sounds sophisticated.

That's also why this lesson names no specific tools or models. The particular systems change constantly; the principles here — noise, shifting patterns, competition, tiny data, and the discipline they demand — don't. Understand those, and you can read any timely piece about the newest AI trading tool without being dazzled by it.

Sources & Further Reading

Educational use only

Educational content only. StockCram isn't a broker or adviser, and we have no affiliation with any institution or tool we mention. Nothing here is a recommendation to trade in any particular way.

Key Takeaways

  • AI learns the pattern; humans write the rule - A rules-based signal is a formula a person writes; a machine-learning signal is a pattern the software learns from labeled examples — like a spam filter trained on emails marked spam or not-spam. Both output a score, not a trade.
  • Four words cover most of it - Features are the input clues, training is learning from history, prediction is scoring new data, and the train/test split is how you catch a model that just memorized the past.
  • Markets are hostile to ML - Prices are mostly noise, the patterns keep shifting, any traded edge tends to erase itself, and decades of data is tiny by ML standards — together they make overfitting extremely easy.
  • It's a pattern-finder, not a money printer - AI genuinely helps sift messy data and propose signals, but a human still validates and risk-manages them. The discipline from earlier lessons matters more when a model you don't fully understand writes the signal.

Continue Learning

Frequently Asked Questions

Most often it fills the signal engine — the box this course focuses on — by learning a pattern from historical examples instead of a human writing the formula by hand. You feed it past data, each example labeled with what happened next, and it works out how to turn inputs into a score. Like a rules-based signal, the output is just a number; the rules, risk checks, and execution around it are ordinary software a person designed. That's the clearest place to see AI at work, though more advanced systems also apply machine learning to execution, order routing, transaction-cost and market-impact estimation, and risk monitoring.

Only in who writes the pattern. In a rules-based signal a person writes the formula directly, such as 'buy if price is above its 200-day average.' In a machine-learning signal the person supplies many labeled examples and the software learns the formula itself. Both drop a score into the same signal-engine slot and both must be tested on data they've never seen — swapping one for the other doesn't change the test that matters.

Overfitting is when a model memorizes the noise in its training history — including pure luck — instead of a real, repeatable pattern. It then looks brilliant on the past and falls apart on new data. Flexible models on markets are especially prone to it because financial data is noisy and scarce, which is why you always check a model on a train/test split it was never trained on.

Four reasons stack up. Signal-to-noise is terrible — prices are mostly randomness. Markets are non-stationary, so patterns decay as conditions shift. They're reflexive and competitive, so any edge that's found and traded can erase itself. And the data is tiny — decades of daily prices is only thousands of points, small by ML standards. Together these make it very easy to believe you've found an edge that isn't real.

No tool can do that reliably, and this lesson makes no such claim. Machine learning is a pattern-finder, not a crystal ball. It can help sift messy data and propose candidate signals, but markets are noisy, shifting, and competitive, so durable edges are rare and hard to confirm. Any proposed signal still has to be validated on unseen data and wrapped in risk controls before it's trusted — and past patterns never guarantee future results.

Share