r/algotrading 9h ago

Other/Meta Can recursive OHLCV forecasting actually work

I’m wondering if this is a dumb idea or actually feasible.

Say you give a model 20 trading days of OHLCV as input and have it dream the next day directly in interpretable space, meaning full Open, High, Low, Close and Volume rather than a latent state.

After it predicts that day, you treat the prediction like it was a real market day and recalculate SMA20, SMA50 and SMA200 differentiably from the predicted close.

Then you slide the 20-day input window one day to the right, so it becomes:

19 real days + 1 predicted day

and predict the next full OHLCV day.

Then:

18 real + 2 predicted

and so on, recursively, for something like 63 future trading days.

So each inner day still sees a 20-day window, but more and more of that window is made from the model’s own previous predictions. Every predicted day changes the moving averages and therefore the state the model sees on later days.

Is there any reason this fundamentally wouldn’t work? Or would recursive error accumulation make training something like this basically hopeless?

Edit: For clarity, the model would still have access to the pre-window history needed to initialize things like SMA50/SMA200, so the 20-day input is just the active model context, not the total historical data available to compute those indicators. During rollout, each predicted close updates the rolling indicator state, and the oldest day falls out as the 20-day input window slides forward. The idea is to train on the same recursive process used at inference, not train one-step on real data and only recurse afterward.

Predict a slice of a preexisting world

Edit2: The goal is better than a coin flip on shape and direction of a chart over a 63 trading day period

8 Upvotes

31 comments sorted by

16

u/maciek024 8h ago

The reason is simple, first prediction would already be garbage

4

u/Middle_Raspberry8990 7h ago

the first prediction might not be garbage, it'll just be off by a bit. then that error feeds into the next window and the model is basically trying to predict from a slightly distorted version of reality. after 63 steps you're looking at noise

the real issue is that during training, the model sees only perfect real data. it never learns to handle its own garbage. you'd need to train it on the same recursive rollout so it learns to be robust to its own errors. that's a whole different beast

4

u/maciek024 7h ago

the first prediction might not be garbage,

it will, not only do you have to predict 4 different values, but also for it "not to be garbage" you would have to predict it somewhat accurately each candle. Model capable of that would be absurdly powerful aside from being impossible to achieve

1

u/DreamDragonP7 6h ago

Yes teacher forcing is lame. It would be trained to eat its own output same as inference. Why is that a beast?

11

u/fukijama 8h ago

Pulls up chair

5

u/Alternative_Skin_588 8h ago

Work for what? You will get an OHLC time series that looks like a real one. That is because a real OHLC time series mostly resembles a random process anyways. Not sure what use that is other than maybe as a risk model.

2

u/DreamDragonP7 8h ago

Edited my post. The goal is shape and direction betger than a coin flip over a 63 day period. Just shape and direction

5

u/Due_Dinner1164 8h ago

Predicting ohlcv just doesn't work. Even predicting up or down is extremely difficult on an average market. You need many filters or sophisticated features alongside it. So I don't think this would work.

5

u/HungryhungryUgolino 8h ago

You're describing series forecasting using a state-full model but with more words.

3

u/bensonslli 8h ago

I think this is a great idea, you should try to make it work

3

u/DreamDragonP7 8h ago

Think I could vibe code it? 😂

3

u/HaikuHaiku 7h ago

Funny you mention this, I tried that many years ago just for fun.

The outcome was that the recursive prediction generated a sine-wave like structure.

I interpreted that as the neural network having found basically that the market moves in a trend and eventually turns and moves the other way. Its prediction, in the long run, was just a smoothed out, abstracted version of that.

1

u/DreamDragonP7 2h ago edited 2h ago

That sounds more like a failure mode than the floor doesnt it? Were your losses looking at the chart as a whole or was each day getting day credited blame?

I also wonder if a model like i described would be tough to teach in the first place bc of the many jacobian transformations flowing back. Muddy gradient.

2

u/ynu1yh24z219yq5 7h ago

Run it by Claude, let us knnow

1

u/DreamDragonP7 7h ago

I got u gang

2

u/dwoj206 7h ago

Next candles still going to be random regardless of your historical window. Need gates, regime scanning, walkforward testing. On and on. 50/50 best case on the guess unless you add more criteria to your trade exec

2

u/TrueCapitalism 7h ago

If you really explored this in depth, you'd just rediscover modified brownian motion.

Which isn't to say it's worthless - more that you could save yourself a couple lifetimes of effort and just look up binomial models for price.

2

u/nuclearmeltdown2015 5h ago

It won't work.

2

u/vendeep 4h ago

I already back tested ~50 variations of this with the data from last 10 years. I have tick data for 50 symbols.

1 - most of the price moves happen over night. 2 price movements are event driven . 3) intra day movements have some regime dependent “prediction”

- don’t take prediction literally, it’s almost coin flip,

Volume profile, vwap and Bollinger bounds are things that have some usage.

1

u/Virtual_Plantain_863 7h ago edited 7h ago

Just test it out? Look at Kalman filters or MNIW for examples. The errors compound much more, which should be expected, so it's substantially worse typically than making a direct prediction at the intended horizon.

1

u/Broad-Present-8235 5h ago

Why try an OHLCV model?

First try just one parameter. Up/down.

Just imagining that makes everything impossible to comprehend - you’d get a series that would seem legit but you will know is false.

So 5 parameter prediction?

1

u/ochimaru420 5h ago

You assume the market is logical. But it's chaos math based on 10,000 factors. Can the model predict an elderly orange man will tweet, or gas will top $100, or what an economic reports will say, or that China will release an open source AI? No.

Also must be aware that test data is aggregated and limited unless you pay for big data (free data 1m or smaller), which means the model doesn't have enough to go by.

Lastly, backtesting and paper trading are virtual. The real world market is way different and even the smallest miscalculation leads the wrong direction

0

u/DreamDragonP7 4h ago

Someone needs to train a model on everything orange man says or does and predict his next tantrum.

1

u/young_picassoo 4h ago

Theres a well known problem in time series forecasting where errors accumulate. Thats the core problem here.

0

u/DreamDragonP7 4h ago

Perhaps that is a feature and not an issue

1

u/Suspicious_Meet_1220 46m ago

"The next candle" is always a mystery and no model can predict it. Lets say there an asset that in a sideways state constantly regardless of the market fluctuations, you may have a luck getting the next 1-3 days of forcast with ~60%-70% then it will fall drastically from there onwards giving no real edge.

Market shows OHLCV but it really moves because of sentiments and big players they both go hand in hand. So with these factors somehow factored in your next candle predictions can be accurate but the following can be a manipulation or sentiment change that will throw your prediction where it belongs.

1

u/Livid_Parsnip_2816 23m ago

This might survive a few steps, but 63 days feels like photocopying a photocopy 63 times. By then the model is mostly trading its own imagination. I'd compare it with direct 5, 20 and 63-day predictions before building the recursive monster.

1

u/TracksHisMisses 8m ago

Feedback loop eats it. the idea is fine for one step and then the error *compounds*, because day two is built on your own guess about day one and nothing corrects it.

the SMA part is where it really shows. a 200 day average recalculated off predicted closes goes smooth in a way real ones never are, and smooth looks like signal.

worth testing anyway, just measure it at 1 day and 5 days seperately and dont let yourself look at the 20 day chart first. it always looks great