MLP Neural Network Class for MetaTrader

MLP Neural Network Class for MetaTrader
Download ALL MT5 librarys (391)
YouTube Video Thumbnail



Similar MetaTrader Tools

MLP Neural Network Class for MetaTrader

Info

The MLP Neural Network Class for MetaTrader is a Library for MetaTrader 5 that the cnetmlp class provides a multilayer perceptron (mlp) implementation. Key Feature:The input vector and network structure are decoupled, allowing for flexible input sizes and network configurations.

Usage

This tool is typically used for enhancing chart analysis and decision making.

Platform

This Library works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Libraries folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use MLP Neural Network Class for MetaTrader

1. Storage: Place library files in the MQL/Libraries directory to ensure they are accessible to your projects.

2. Implementation: Include the library in your code using the #import directive, ensuring you match the exact function names and parameters.

3. Compilation: Ensure the library is present in the directory before you compile your main EA or script, as the compiler links them during this phase.

4. Management: Keep libraries organized in sub-folders if you manage many custom functions to maintain a clean project structure.

Frequently Asked Questions

Q: What is a library file used for? A: Libraries store reusable code modules, allowing you to centralize common logic used by multiple EAs or indicators.

Q: Is a library executable? A: No, libraries are non-executable files containing functions; they must be imported into an EA, indicator, or script to function.

Q: Can I update a library while the platform is running? A: You should compile your EA or script after updating a library to ensure the latest code changes are integrated.

What this tool does

The cnetmlp class provides a Multilayer Perceptron (MLP) implementation.

Typical Use Case

This Library excels in automated trading and technical analysis on MetaTrader 5.

Compatible Platform & Setup

This Library works on MetaTrader 5. Place the file in the MQL5/Libraries folder and restart the terminal.

Description & Settings

Related: as q neural net pure mq l5 neural network library - another powerful library for MetaTrader 5 traders.

The cnetmlp class provides a Multilayer Perceptron (MLP) implementation.

Also recommended: cexecutionsafety: network latency guard for metatrader 5 expert advisors - similar library with strong performance on MetaTrader 5.


Key Feature:
The input vector and network structure are decoupled, allowing for flexible input sizes and network configurations.

Input Data Handling:
Input data should be normalized to either the -1 to 1 range or the 0 to 1 range.
For data in the -1 to 1 range, the hyperbolic tangent activation function is recommended.
For data in the 0 to 1 range, the sigmoid activation function should be used.

Network Structure:
The network features a layer-by-layer structure with direct signal flow.
The network architecture is defined by a one-dimensional array, where each element specifies the number of neurons in a corresponding layer.
There are no limitations on the number of layers or neurons, and the network can consist of a single neuron.

Neuron and Output Configuration:
Each neuron accepts multiple inputs based on its position in the network and produces a single output.
To obtain N outputs from the network, the final layer must contain N neurons.

Learning Algorithm:
The network utilizes the IRprop learning algorithm.
Training involves providing input and output data in one-dimensional arrays, organized vector by vector.
The learning process can be terminated based on a specified number of learning epochs or a target error tolerance.

Initialization:
The network is created using the class's parametric constructor.

Training Process:
The `learn` method facilitates network training. It requires the number of training patterns, input data array, output data array, the number of learning cycles, and the permissible learning error.
The results of the training, including the Mean Squared Error (mse) and the number of completed learning cycles (epoch), can be accessed via class variables.

Prediction:
The `calculate` method generates network responses. It takes an input vector array and returns the corresponding network response in an output vector array.

Data Persistence:
The `save` and `load` methods enable the persistence of the network model.
`save` requires a file handle opened with `file_write` and `file_bin` flags.
`load` requires a file handle opened with `file_read` and `file_bin` flags.
Only the learning errors and the weight array are saved to the file.
It is crucial to verify the compatibility of the network structure before using the `load` method.

Usage Example:
An example demonstrating the usage of the class is provided in an attached specimen.
Ensure the class and specimen files are located in the same directory for proper functionality.

You may also like: rbf Neural Network Class - excellent alternative for library users on MetaTrader 5.

Source Code

#property copyright "robotfx"
#include "class_netmlp.mqh"
double vector[2];   // input vector
int snn[]={3,1};    // network structure: the first layer  - 3 neurons, the second (output) one - 1 neuron
double out[1];      // the network responses array
double inppth[]={1,1,1,-1,-1,1,-1,-1}; // input teaching data array
double tchth[]={-1,1,1,-1};            // output teaching data array
double inpps[]={1,1,1,0,0,1,0,0};      // input teaching data array
double tchs[]={0,1,1,0};               // output teaching data array
void onstart()

.......

Leave your opinion, ask a question, share some knowledge

Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.