Discussion of article "How to use ONNX models in MQL5" - page 3

 

Reviews on applications (objects, models and tools)

1. survey on the application of deep learning in algorithmic trading (2021)

Algorithmic trading is one of the most concerned directions in financial applications.

Compared with traditional trading strategies, algorithmic trading applications perform forecasting and arbitrage with higher efficiency and more stable performance.

Numerous studies on algorithmic trading models using deep learning have been conducted to perform trading forecasting and analysis.

In this article, we firstly summarise several deep learning methods that have shown good performance in algorithmic trading applications, and briefly introduce some applications of deep learning in algorithmic trading.

We then try to provide the latest snapshot application for algorithmic trading based on deep learning technology, and show the different implementations of the developed algorithmic trading model.

Finally, some possible research issues are suggested in the future.

The prime objectives of this paper are to provide a comprehensive research progress of deep learning applications in algorithmic trading, and benefit for subsequent research of computer programme trading systems.


2. Deep Learning for Financial Applications : A Survey (2020)

Computational intelligence in finance has been a very popular topic for both academia and financial industry in the last few decades.

Numerous studies have been published resulting in various models. Meanwhile, within the Machine Learning (ML) field, Deep Learning (DL) started getting a lot of attention recently, mostly due to its outperformance over the classical models.

Lots of different implementations of DL exist today, and the broad interest is continuing. Finance is one particular area where DL models started getting traction, however, the playfield is wide open, a lot of research opportunities still exist.

In this paper, we tried to provide a state-of-the-art snapshot of the developed DL models for financial applications, as of today.

We not only categorised the works according to their intended subfield in finance but also analysed them based on their DL models.

In addition, we also aimed at identifying possible future implementations and highlighted the pathway for the ongoing research within the field.






3. Financial Time Series Forecasting with Deep Learning : A Systematic Literature Review: 2005-2019 (2019)

Financial time series forecasting is, without a doubt, the top choice of computational intelligence for finance researchers from both academia and financial industry due to its broad implementation areas and substantial impact.

Machine Learning (ML) researchers have come up with various models and a vast number of studies have been published accordingly.

As such, a significant amount of surveys exist covering ML for financial time series forecasting studies.

Lately, Deep Learning (DL) models started appearing within the field, with results that significantly outperform traditional ML counterparts.

Even though there is a growing interest in developing models for financial time series forecasting research, there is a lack of review papers that were solely focused on DL for finance.

Hence, our motivation in this paper is to provide a comprehensive literature review on DL studies for financial time series forecasting implementations.

We not only categorised the studies according to their intended forecasting implementation areas, such as index, forex, commodity forecasting, but also grouped them based on their DL model choices, such as Convolutional Neural Networks (CNNs), Deep Belief Networks (DBNs), Long-Short Term Memory (LSTM).

We also tried to envision the future for the field by highlighting the possible setbacks and opportunities, so the interested researchers can benefit





 

CNN LSTM neural network created by CHATGPT

# Import necessary libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.preprocessing import MinMaxScaler
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, LSTM, Dropout, Conv1D, MaxPooling1D, Flatten

# Load the dataset
df = pd.read_csv('https://query1.finance.yahoo.com/v7/finance/download/AAPL?period1=1411958400&period2=1636521600&interval=1d&events=history&includeAdjustedClose=true')

# Preprocess the data
scaler = MinMaxScaler(feature_range=(0, 1))
scaled_data = scaler.fit_transform(df['Close'].values.reshape(-1, 1))

# Split the data into training and testing sets
training_size = int(len(scaled_data) * 0.7)
testing_size = len(scaled_data) - training_size
training_data = scaled_data[0:training_size, :]
testing_data = scaled_data[training_size:len(scaled_data), :]

# Function to create input features and labels for model
def create_dataset(dataset, look_back):
    data_X, data_Y = [], []
    for i in range(len(dataset)-look_back-1):
        a = dataset[i:(i+look_back), 0]
        data_X.append(a)
        data_Y.append(dataset[i + look_back, 0])
    return np.array(data_X), np.array(data_Y)

# Create input features and labels for training and testing sets
look_back = 60
X_train, y_train = create_dataset(training_data, look_back)
X_test, y_test = create_dataset(testing_data, look_back)

# Reshape the input data for CNN-LSTM model
X_train = np.reshape(X_train, (X_train.shape[0], X_train.shape[1], 1))
X_test = np.reshape(X_test, (X_test.shape[0], X_test.shape[1], 1))

# Define and compile the CNN-LSTM model
model = Sequential()

model.add(Conv1D(filters=32, kernel_size=5, activation='relu', input_shape=(look_back, 1)))
model.add(MaxPooling1D(pool_size=2))
model.add(Dropout(0.2))

model.add(Conv1D(filters=64, kernel_size=5, activation='relu'))
model.add(MaxPooling1D(pool_size=2))
model.add(Dropout(0.2))

model.add(LSTM(50, return_sequences=True))
model.add(Dropout(0.2))
model.add(LSTM(50))
model.add(Dropout(0.2))

model.add(Dense(1))

model.compile(loss='mean_squared_error', optimizer='adam')

# Train the model on the training data
model.fit(X_train, y_train, epochs=100, batch_size=32)

# Use the model to make predictions on the testing data
y_pred = model.predict(X_test)

# Rescale the data back to original values
y_pred = scaler.inverse_transform(y_pred)
y_test = scaler.inverse_transform(y_test.reshape(-1, 1))

# Plot the original and forecasted values
plt.plot(y_test, label='Actual')
plt.plot(y_pred, label='Predicted')
plt.xlabel('Time')
plt.ylabel('Close Price')
plt.title('AAPL Stock Price Forecast')
plt.legend()
plt.show()

Execution result in Jupyter Notebook
 
Did you expect something different? Only through one's own experience and knowledge can there be a result.
 
Vladimir Perervenko #:
Did you expect something different? Only through one's own experience and knowledge can there be a result.

I rather did not expect that such a thing is possible now, the technology is impressive. I agree that even with such tools, serious labour is required, and experience is the son of hard mistakes....

 
Vladimir Perervenko #:

Transfer preprocessing to MT is not a problem, I really want to test the system in MT tester, in python/R I need to write my own tester, fraught with errors.

 
Vladimir Perervenko project consists of three phases:
  • preprocessing (a lot of things)
  • Model selection, training, optimisation, etc.
  • implementation

Using ONNX models in µl solves the implementation issue. However, not all models and not quite easy.

Training and optimisation of models is solved by a separate process in Python.

But of all the above, the first stage is the most time-consuming, highly creative and the most important. And it is impossible to realise it on µl. We don't consider primitive scaling as preprocessing. And the folk wisdom says: "Garbage in - rubbish out". There is too much to be additionally developed and implemented in MCL for full use of MO only on MCL. It is impossible to embrace the immense, especially since it is constantly expanding ...

Is it really that bad? After all, a lot of articles have already been written about neural networks. And there are even some where everything is "simple".....

 
Vladimir Perervenko project consists of three phases:
  • preprocessing (a lot of things)

But of all the above, the first stage is the most time-consuming, highly creative and the most important. And it is impossible to implement it on µl.

As far as I understand, we are talking about the difficulty of calculating some price functions that act as features of the network.

Can you give an example, perhaps there will be those here who will present an implementation of these things.

 
Denis Kirichenko #:

Is it really that bad? I mean, a lot of articles have already been written about neural networks. And there are even some where everything is "simple"....

It's not bad. Everything is in a very embryonic state compared to the modern development of preprocessing functionality.

I've been programming in R for quite a long time. I have been using Python not so long ago and the main thing I noticed while studying machine learning projects (packages) in Python is almost complete absence of preprocessing. The approach is that the model will take everything out. This is neither bad nor good. This is the approach that has developed historically.

In contrast, R has a huge arsenal of preprocessing with an understanding of what it's all for.

Although recently there has been a mutual borrowing of many useful developments.

I mean that it is impossible to cover the vastness, and developers strive to do it. To port what is written in C - yes, but to rewrite everything in MKL.....

Regarding ONNX. The area is new, very promising, rapidly developing and in demand. It means that there will be a possibility to drive into ONNX and preprocessing. TensorFlow already has layers of preprocessing, though simple, but still. You need to try it out, it will come in handy.

Of course it looks more attractive to use ONNX in training, but this is only for Linux. Maybe WSL experts can use it somehow.

 
To use this I would rather use a simple engulfing pattern😀 complicated for no good reason
 
it's great thanks to this article that i know how to get data from mt5 to python and traling model in python then get model from python to generate ea on mt5, i don't know if this model more great than traditional models but i'm sure sure it will make different models. it is future
How to use ONNX models in MQL5
How to use ONNX models in MQL5
  • www.mql5.com
ONNX (Open Neural Network Exchange) is an open format built to represent machine learning models. In this article, we will consider how to create a CNN-LSTM model to forecast financial timeseries. We will also show how to use the created ONNX model in an MQL5 Expert Advisor.