as q neural net pure mq l5 neural network library
Info
The as q neural net pure mq l5 neural network library is a Library for MetaTrader 5 that asq neuralnet is a comprehensive neural network library developed entirely in native mql5, eliminating the need for external dependencies like dlls or python bridges. this library empowers mql5 developers with a full-featured deep learning framework, comprising:- a dense matrix algebra engine with over 40 operations, including multiplication, transpose, hadamard, he/xavier initialization, and nan detection.
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 as q neural net pure mq l5 neural network library
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
asq neuralnet is a comprehensive neural network library developed entirely in native mql5, eliminating the need for external dependencies like dlls or python bridges.
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: MLP Neural Network Class for MetaTrader - another powerful library for MetaTrader 5 traders.
asq neuralnet is a comprehensive neural network library developed entirely in native mql5, eliminating the need for external dependencies like dlls or python bridges.Also recommended: rbf Neural Network Class - similar library with strong performance on MetaTrader 5.
this library empowers mql5 developers with a full-featured deep learning framework, comprising:
- a dense matrix algebra engine with over 40 operations, including multiplication, transpose, hadamard, he/xavier initialization, and nan detection.
- 13 activation functions with analytical derivatives: relu, leakyrelu, elu, selu, sigmoid, tanh, softmax, swish, mish, gelu, softplus, hardsigmoid, and linear.
- dense layers supporting forward and backward propagation, dropout, and gradient clipping.
- 3 optimizers: sgd with momentum, adam, and adamw (decoupled weight decay).
- 7 learning rate schedulers: constant, step decay, exponential, cosine annealing, linear, reduceonplateau, warmup, and cyclic lr.
- 5 loss functions: mse, mae, huber, cross-entropy, and binary cross-entropy.
- a complete training pipeline with mini-batch sgd, fisher-yates shuffle, and epoch logging.
quick start:
building a neural network is straightforward, requiring just 6 lines of code. here's an example:
cneuralnetwork net;
net.init(32); // 32 input features
net.addlayer(64, act_relu); // hidden layer 1
net.addlayer(32, act_relu, 0.2); // hidden layer 2 + dropout
net.addlayer(3, act_softmax); // output: buy/sell/hold
net.build();
training is equally simple, with a single function call:
net.setoptimizer(opt_adam, 0.001);
net.setloss(loss_cross_entropy);
net.fit(trainx, trainy, 100, 32);
prediction is also a one-line operation:
int action = net.predictclass(features); // 0=buy, 1=sell, 2=hold
use cases:
- train classification models for trading signals (buy/sell/hold).
- perform price direction regression using mse or huber loss.
- recognize patterns in candlestick formations.
- detect market regimes (trending, ranging, volatile).
- analyze feature importance.
- approximate q-value functions for reinforcement learning agents.
performance:
- inference latency: < 0.1ms for typical architectures with under 1000 parameters.
- memory usage is proportional to the total number of parameters (e.g., 5kb for a 32โ64โ32โ3 network).
- no dynamic allocation during inference.
- numerical stability features: nan detection, gradient clipping, and safe softmax with max-subtraction.
installation:
place the 5 library files in mql5/include/algosphere/neuralnet/ and include the main header:
#include <algosphere/neuralnet/nn_network.mqh>
the demo script showcases matrix operations, activation functions, xor classification, and synthetic market direction prediction.
library files:
- nn_matrix.mqh (908 lines) - dense matrix algebra engine.
- nn_activations.mqh (300 lines) - 13 activations + derivatives.
- nn_layer.mqh (374 lines) - dense layer with forward/backward/dropout.
- nn_optimizer.mqh (454 lines) - sgd/adam/adamw + 7 lr schedulers.
- nn_network.mqh (734 lines) - complete feedforward network with training.
- asq_neuralnet_demo.mq5 (283 lines) - 4 runnable demonstrations.
total: 3,053 lines of pure mql5.
technical notes:
- weight initialization: he init for relu-family, xavier for sigmoid/tanh.
- box-muller transform for normal distribution (mql5 native mathrand).
- softmax + cross-entropy gradient shortcut (ลท - y) to avoid full jacobian.
- inverted dropout (scaled during training, identity during inference).
- fisher-yates shuffle for mini-batch training.
- gradient norm clipping per layer (default max norm = 1.0).
You may also like: PNN Neural Network Class - excellent alternative for library users on MetaTrader 5.
Source Code
#property copyright "robotfx"
#property link "https://robotfx.org"
#property version "1.00"
#property script_show_inputs
#include "asq_neuralnet.mqh"
input int inpepochs = 500;
input double inplr = 0.01;
input bool inpverbose = true;
void onstart()
{
.......
⚠ 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.