Home › Guides › LSTM Stock Prediction

WHY BOTS FAILFREENO ACCOUNTAUTOMATED TRADE BOTSLSTM StockPredictionThe arithmetic of how bots failEDUCATION ONLY | NO SIGNALSEXAMPLE NUMBERS ARE LABELLEDAUTOMATED TRADE BOTSautomatedtradebots.com
A free page on lstm stock prediction. Education only, with example numbers labelled.
WHY BOTS FAIL

LSTM Stock Prediction

Short answer

An LSTM (long short-term memory) is a kind of neural network built to read sequences, such as a run of daily prices. It keeps a running memory and decides what to keep and what to forget at each step.

An LSTM reads a window of past values and outputs a forecast. The famous demo chart where the forecast hugs the price shows the model repeating yesterday, not seeing tomorrow.

The page explains the idea in plain words, works through the arithmetic with a table, and shows how it hits grid, martingale and DCA bots, then tells you what to check before you run one.

  • A worked example with real arithmetic
  • How it hits grid, martingale and DCA bots
  • How to check for it before you run a bot
  • No advice, no signals, no profit promises

Last reviewed 28 October 2026. Education only, not advice.

Free, no account Runs in your browser Worked numbers shown Not advice Examples labelled

Ready to go further

Next: see why accuracy is not profit

The AI stock prediction guide takes a model that is right more than half the time and shows how costs and win size can still make it lose.

Read the guideFree, no account
Reading time5 minutes
Worked exampleExact arithmetic
Tools linked0 on this page
Reviewed28 Oct 2026

What is included

  • What it is, in plain words
  • The formula or mechanism, with exact arithmetic
  • How it hits grid, martingale and DCA bots
  • A check you can run before you switch a bot on

Who it is for

  • People who run or plan to run a trading bot
  • Anyone reading a backtest or a bot sales page
  • Readers who want the numbers, not the pitch
  • Not advice, and not a signal service
Price and the model line, first 40 days (made-up random walk)93102day 010203039Solid: price. Dashed: the model line, one day behind.Made-up random walk, no pattern by construction. Calculated by us on 29 Oct 2026, exact for this seed.
The picture for this page. Example numbers are made up unless the page says they were calculated.

Key facts

  • An LSTM (long short-term memory) is a kind of neural network built to read sequences, such as a run of daily prices. It keeps a running memory and decides what to keep and what to forget at each step.
  • Fed prices, a model learns that the best cheap guess for tomorrow is close to today. Its line then tracks the real price closely, one day late.
  • A close fit on price level is not a forecast. In our made-up example the model line matched the price level at 98.7 out of 100 and called the direction right on 48.4% of 248 days, less than a coin flip.
  • The honest test is on returns or direction, on data the model never saw, after costs. See AI stock prediction for why accuracy alone is not profit.
  • Everything numeric on this page is made up. It names no product and makes no claim about any real model.

What a sequence model does

Prices come in a row, and the order matters. A plain model that looks at one day at a time forgets the rest. A sequence model reads a window, for example the last 60 days, one step at a time and carries a memory forward.

An LSTM does this with gates. At each step it looks at the new value and its own previous memory, and decides how much of the old memory to keep, how much of the new value to store, and how much to pass on as output. The numbers inside the gates are the model's settings. Training is the process of adjusting them so that the outputs match past targets as closely as possible, usually by minimising an average error.

That is a fitting method, not a source of insight. If the target is "tomorrow's price" and the data is a price series, the settings that minimise the error are the ones that predict something very close to today's price, because daily changes are small next to the price level.

Why the demo chart looks so good

Many tutorials plot the model's forecast over the real price. The two lines hug each other and it looks as if the model sees the future. Look closely and the forecast is the real line shifted one step to the right. Each forecast point is nearly the previous real point. The chart is mostly a lag.

The reason the fit looks so tight is the scale. A price of 100 that moves by 0.7 on a typical day changes by well under one percent. A forecast that is only 0.6% off on average still looks perfect when drawn on a chart whose axis runs from 90 to 110. The picture hides that the miss is the same size as the move you wanted to predict. A related trap is to score a model by how well it matches the level of price. Two unrelated rising series match well in level. See look-ahead bias for another way a good-looking test arises.

How to test it properly

  • Predict the change, or the return, not the level. The target is what you could trade on.
  • Compare with the do-nothing baseline: "tomorrow equals today". A model must beat it, on returns, to add anything.
  • Test on data after the training data, in time order. See backtesting.
  • Score the direction and the size, then subtract costs. See slippage.

Worked example: a model that only repeats yesterday

Everything here is made up and is pure noise by construction. We generated 250 days of a random walk starting at 100, with no pattern in it. The stand-in model forecasts each day as yesterday's close plus 0.3 of yesterday's move. That is roughly what a fitted sequence model ends up doing on a series like this. We then scored it two ways.

DayYesterday closeModel forecastActual closeErrorModel saysActualRight?
2100.17100.22100.270.05%upupyes
3100.27100.30100.000.31%updownno
4100.0099.91100.020.11%downupno
5100.02100.03101.411.36%upupyes
6101.41101.83101.490.33%upupyes
7101.49101.52101.890.37%upupyes
8101.89102.01100.121.89%updownno
9100.1299.5899.810.23%downdownyes

Calculated by us on 29 Oct 2026, exact for this seed. These are the first eight forecasts. Each error is small as a percent of price, and the model got the direction right on 5 of 8 in this window. Over all 248 forecasts the picture is clear:

  • Average miss: 0.60% of price. That looks tiny, and it is why the chart looks perfect.
  • Match of forecast to price level: correlation 0.99. Almost a perfect match, because both lines are the same slow-moving series.
  • Match of forecast change to actual change: correlation -0.06. That is no relationship at all, which is what you expect when the data has no pattern.
  • Direction right: 48.4% of days, no better than a coin flip.

The model looks excellent on the first score and worthless on the last two, and the data and forecasts did not change between them. The first score is dominated by the fact that price today is close to price yesterday.

Two scores for the same model line (made-up, 248 days)98.7Level matchcorrelation x 10048.4%Direction rightpercent of days50%Coin flipfor referenceMade-up random walk. The model line is the last price plus 0.3 of the last move. Calculated by us on 29 Oct 2026, exact.
The same forecast line scores about 99 out of 100 on level and below a coin flip on direction.

How it hits bots

  • A bot that trades the forecast sees a signal that follows the price one step late. In a trend it looks right and in a reversal it is wrong, so the result depends on the market, not on the model. Compare EMA crossovers, which also lag.
  • Retraining often only teaches the model the recent past again. See overfitting.
  • A good score in a notebook with leaked or shuffled data does not carry to live trading. See machine learning trading.

What this page does not tell you

It does not say an LSTM cannot find a real pattern in real data, and the stand-in model here is not a trained network. Real models do have more inputs and can pick up more than the last move. The point is that a forecast chart hugging the price is not evidence of skill, and that the checks above are the minimum before any model gets money. All numbers are made up.

FAQ

Frequently Asked Questions

What is an LSTM?

It is a neural network for sequences. It reads a series one step at a time and keeps a memory, using gates to decide what to keep and what to forget.

Can an LSTM predict stock prices?

It can be fitted to past prices, but a close fit does not mean it predicts. The common result is a forecast that follows the price one step late. The test is direction or return on data it never saw, after costs.

Why does my LSTM prediction chart look so accurate?

Daily price changes are small next to the price level, so a forecast near yesterday's price looks almost perfect on a chart. The line is usually the real price shifted one step.

What should I predict instead of the price?

Predict the change or the return, and compare with the baseline that tomorrow equals today. Only a result that beats the baseline out of sample is worth looking at.

Does a more complex network help?

Not by default. More settings give more room to fit noise. Compare with a simple baseline and test in time order.

Are the numbers on this page real?

Example numbers are made up to show how the maths works, and the page says so. A figure only counts as exact when the page says it was calculated on a stated date. Nothing you enter in a calculator leaves your browser.

Can I use this to decide whether to run a bot?

It can show whether a bot's numbers hold together and how much an account can lose. It cannot say what the market will do, and it is not advice. Use it to ask better questions, then read the terms of your own broker or exchange.

Is this financial advice?

No. It is general education. The series and the model are made up and nothing here is a recommendation.

Know the Risk Before You Run It

Free calculators and guides, added every week. Leave your details and we will email you when new ones go up.

Trading carries a risk of loss