MLP Neural Network Class – library MetaTrader 5

CNetMLP provides multilayer perceptron (MLP).

The feature of the class is that input vector and network structure notions are separated, i.e. input vector and network structure descriptions are not connected to each other.

The size of the input vector can have any value within reasonable limits.Β Input data should be normalized, i.e. the data should be within the range -1 .. 1 or 0 .. 1. Various activation functions are applied for the network depending on the type of the used data: hyperbolic tangent should be used for -1..1 data range, while sigmoid is used for 0..1 data range.

The network has a layer-by-layer structure with a direct signal transmission. The network structure is described by a one-dimensional array, where the value of the array element determines the number of neurons in the appropriate layer. The number of layers and neurons is not limited. The network may consist of a single neuron.

Each neuron has multiple inputs, defined by its place in the network, and one output. If you need the network to give out N responses, the last layer should contain N neurons. The learning algorithm is iRprop. Input and output training data are located in one-dimensional arrays vector by vector. The learning process is limited either by the number of learnnig epochs or by a permissible error.

Alternative:  XWAMI_HTF - indicator MetaTrader 5

Creation of the network is declared to be the class parametric constructor.

CNetMLPΒ Β *net=new CNetMLP(

the number of layers, network structure array, input vector size, activation function type: 0 - sigmoid, 1 - hyperbolic tangent).

Network teaching is provided by calling the Learn method (the number of teaching patterns, input data array, output data array, the number of learning cycles, permissible learning error). Teaching result can be checked through the class variables: mse – the learning error and epoch – the number of accomplished learning cycles.

Calculate method (input vector array, network response array) is used for getting the network response.

Save (open the file handle with FILE_WRITE and FILE_BIN flags) and Load (open the file handle with FILE_READ and FILE_BIN flags) methods are intended for saving the network to a file and loading the network from the file respectively. Only learning errors and the weight array are saved to the file. Compliance of the created and the downloaded networks must be verified before the Load method (handle) is used.

Using of the class is shown in the attached specimen. The class and the specimen files must be placed in one folder.


πŸ“ˆ ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks