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.
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
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.
| Day | Yesterday close | Model forecast | Actual close | Error | Model says | Actual | Right? |
|---|---|---|---|---|---|---|---|
| 2 | 100.17 | 100.22 | 100.27 | 0.05% | up | up | yes |
| 3 | 100.27 | 100.30 | 100.00 | 0.31% | up | down | no |
| 4 | 100.00 | 99.91 | 100.02 | 0.11% | down | up | no |
| 5 | 100.02 | 100.03 | 101.41 | 1.36% | up | up | yes |
| 6 | 101.41 | 101.83 | 101.49 | 0.33% | up | up | yes |
| 7 | 101.49 | 101.52 | 101.89 | 0.37% | up | up | yes |
| 8 | 101.89 | 102.01 | 100.12 | 1.89% | up | down | no |
| 9 | 100.12 | 99.58 | 99.81 | 0.23% | down | down | yes |
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.
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.
Keep Going
Related Tools and Guides
Keep exploring
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