@Chris70 don't mind don't mind, they are chatty, go on !
@Icham Aidibe We're good..
@Enrique Dangeroux thanks for your answer. It would be
interesting to know more about what you've tried in the field of forecasting.
In the lower picture I would say the purple line has learned to make a slightly lagged copy of the green line and no actual forecast ;-) if I'm
interpreting correctly. That's NOT what I'd like to see ;-) [hope you don't mind..]
I once did the sine wave experiment, too. I have confirmed that my LSTM code is working and in general able to do time series forecasting in the
case of objective data like a sine wave function. So the question refers more to the possibilities of quantifying the significance of
I think you are completely right, that a significant forecasting ability (=not technically, but as a quality of the application
specifically in the forex market) should also be visually noticeable in the chart. This is no contradiction to wishing for some kind of
quantification measure. The latter might also come in handy if I later compare slight modifications (different number of timesteps,
inputs per timestep, other input length...).
I do of course have an expectaction about what I should see in the "randomness only" case: because the decoder puts out little price pattern
wavelets and not just single price levels, given enough training time the algorithm shouldn't be biased in any direction AT ALL -
if(!) there is nothing to be predicted. I therefore don't expect to see just some noisy output or random zigzag in the randomness case, but
instead I should see just straight horizontal lines instead of price "patterns". Observing any kind of direction would already be a sign of
non-randomness. I'd just like to have some cut-off or "level of confidence" (and don't know a correct statistical method how to get one in
this case). It's not
necessary - but like I said, also for comparison with different settings it should be useful (I won't for example be able to visually
notice a 10% decrease of the prediction's reliability).
I don't mind. Yes, the purple line is the forecast. Like i wrote in previous post, it shows the "naive forecast". It is simply the result of a
well trained LSTM on a random walk. In this case EURUSD with H1 data.
@Chris70 and @Enrique Dangeroux,
How do you prepare your input and output for classification?I mean what do you predict?
Do you predict zig zag? Or do you lag your inputs n bars back and lead your output n bar in future?
We are talking about supervised learning with neural networks here. This means:
- we're feeding our inputs into the model
- the model returns some result, we compare this result to the "true" answer
- we refeed the error back into the model and use this information for small corrections in order to make better predictions next time
If we want classification instead of regression, all we need to do is use 'softmax' as the activation function of the last
layer. Softmax has the property that all results sum up to 1.0 (=100%), so we can consider the individual output results as probability
distributions and the output that get's the highest rating is the "class" that we predicted during that iteration.
Wether classification makes more sense than regression completely depends on what you want your model to predict. In the "cat / dog" image
recognition example, classification makes more sense obviously. With price predictions regression makes more sense, because prices are
continous and therefore don't come in classes.
Do I predict zigzag? Answer: during training on historical data the future is already known, so we know the correct answers (like you say: n
bars into the future), take those as our labels (which we take as the examples for error calculation). Later, in testing and real life trading
we don't know the future obviously. But the network has learned as well as it possibly can to make a best guess what the future will be, based on
known/past data. This means: if we use many outputs (with label sequences instead of single prices), then YES, of course also a zig zag can be
predicted (assuming a zigzag is the most probable extrapolation of prices into the near future; the network will have learned to estimate
exactly that). Of course, the network will be wrong very often. That's just the nature of the markets. I would be very glad already if the
predictions were correct (consistently, on unseen data, without overfitting) in like 55-60% of the time.
If the outputs never show a zig zag pattern, but always just straight horizontal
lines, that simply means that (as a hypothesis) there is nothing to be predicted and the market is not just let's say 90% random,
but 100% random. We'll see...
[edit: I'm not sure if what I'm saying is clear; so as a straightforward answer to your question "what do you predict?":
- at the moment, with the current model, I predict a series of 36 numbers that the decoder part of the autoencoder translates back into a "zig
zag" sequence (/cloud) of 720 predicted future prices of 5 second increments (720*5 seconds=1hour)
- I also added another model that predicts the next 60 M1 candles (OHLC), everything else left unchanged (=autoencoder+multilayer LSTM
no need for telling me that it's impossible to make even remotly acurate predictions on that level, all I want to extract from that is a
dominant price direction for the next hour and a vague estimate on the highs and lows, so that I can make a buy/sell/flat decision and place the
the reason why I'm also experimenting with M1 candles is that I get tick volume as an additional input information that might be helpful for the
network to come up with better predictions; in the end, I'll go with the model that has the lowest error (=outputs versus real prices).]
this much I can tell from early training results:
- the training does indeed start with predicting horizontal (=unbiased) price series, but already after a few dozen iterations it starts
putting out zig zags that look more like actual price patterns (I don't believe that the model is just overcorrecting because the learning
rate was set very low)... let's see where that's going after more training
- you can't have enough timesteps, e.g. working with one week (=235 timesteps of encoded price detail information of 1 hour each) made a
noticeable difference compared to 100 hours of inputs (5% decrease in cost
after single training run over 2 years each)
- less LSTM hidden layers is more, but more neurons per hidden layer is also more
I am still catching up on this very awesome topic. .
I am interested in forecasting trading results instead of price. The idea is to not predict the future price , but to instead have some
arbitrary trading system, eg. Buy when RSI >70 and MA1 > MA50 (or whatever rules), and then while the code runs that test, gathers the
test results and makes predictions about the future result. If future results can be better predicted after training a model, you can run in
parallel to these test trades, the real trade given by the signal of the trained model.
So I'm saying I think it could be easy for machine learning to predict results of a trading system compared to predicting future prices
I have to say that I don't believe much in indicators when it comes to machine learning, because neural networks as a kind of "universal
function" are able to find their own indicators. Taking indicators instead of pure price (and volume) is already a filtered information
that in theory also reduces the accuracy of the model. The only reason why I use the autoencoder (that also reduces the available
information!) is computational performance. I'll probably do later the direct comparison to a LSTM only model (which I worked with is the
past, without being too excited about it).
About your arbitrary systems, I think genetic learning is a good solution. You can define different indicator criteria as "genes" and penalize
or reward their "fitness" according to your trading results. You then regularly (and randomly) recombine those sets of genes and remove the
worst performers from the equation. No predictions involved, just self-improvement via trial and error.
Will look into the genetic learning thanks. Yes I can (without having done machine learning, so not knowing for sure) agree on what you said
about the indicators.
But maybe to for example use an envelope or a Bollinger band to separate a data set into different categories , maybe you ML algo will come up with
some new ideas?
(What I basically meant above though was to look at the results in the strategy tester from any simple trading system and ask whether a ML algo
could predict where those results are going next?)
there have been some good articles on the topic of genetic learning, like this one:
I also wrote a bit about it here: https://www.mql5.com/en/forum/316602 , but there was no interest in the topic at the time
Please enable the necessary setting in your browser, otherwise you will not be able to log in.