- MQL5 93.8%
- C 6.2%
| Dateiname | Letzte Commit-Nachricht | Letztes Commit-Datum |
|---|---|---|
| Images | ||
| Src | ||
| Test | ||
| .gitattributes | ||
| dependencies.json | ||
| LICENSE | ||
| README.md | ||
| ScalerByLeo.mqproj | ||
Build trading systems with automatic data scaling, 3 scaler families (CPU + GPU), and GPU support via OpenCL — all from MQL5.
Features
3 scaler families, CPU + GPU, float & double
// CPU (template<TFlt>, TFlt = float or double)
TSN::MaxMinScaler<TFlt> scaler;
TSN::StandardizationScaler<TFlt> scaler;
TSN::RobustScaler<TFlt> scaler;
// GPU via OpenCL (same interface, same TFlt)
TSN::MaxMinScalerCL<TFlt> scalerGPU;
TSN::StandardizationScalerCL<TFlt> scalerGPU;
TSN::RobustScalerCL<TFlt> scalerGPU;
Every scaler shares the same API: Fit, Transform, InverseTransform, FitTransform, plus Save / LoadByFile / LoadByArr to persist and reload a trained scaler. All CPU and GPU implementations are cross-checked to produce equivalent results.
Matrix scaling
void OnStart()
{
matrixf mtx;
mtx.Resize(16000, 16000);
mtx.Random(0, 20.0);
TSN::MaxMinScaler<float> scaler;
matrixf out;
scaler.FitTransform(mtx, out);
}
Custom column ranges & in-place reconstruction
Scale only a slice of your columns and choose whether the output keeps the full matrix shape (untouched columns preserved) or returns only the scaled slice:
TSN::MaxMinScaler<double> scaler;
scaler.SetRangeEscaler(2, 5); // scale 5 columns starting at index 2
scaler.SetReconstruir(true); // output keeps original shape/columns
scaler.FitTransform(mtx, out);
Error handling
Every operation returns bool and sets a descriptive error you can query instead of failing silently:
if(!scaler.FitTransform(mtx, out))
Print("Scaler error: ", EnumToString(scaler.GetLastScalerError()));
GPU version via OpenCL (real benchmarks)
TSN::MaxMinScalerCL<float> scalerGPU;
scalerGPU.Fit(mtx);
scalerGPU.Transform(mtx, out); // GPU
TSN::MaxMinScaler<float> scalerCPU;
scalerCPU.Fit(mtx);
scalerCPU.Transform(mtx, out); // CPU
GPU = 1,268,040 us
CPU = 2,344,502 us
Benchmark on a 9,600 x 9,600 matrix using an
Intel UHD Graphics 620GPU. SeeSrc/Scaler/Bench/README.mdfor the full set of internal benchmarks (pattern selection for min/max, mean, matrix copy strategy, robust scaling, and the OpenCL upload strategy) that drove the current implementation's performance choices. Used GPU: device #0: GPU 'Intel UHD Graphics 620' with OpenCL 3.0 (24 units, 1100 MHz, 3240 Mb, version 30.0.100.9670, rating 836)
Quick Start
1. Install repository
See Instalation section.
2. Include the scaler in your script
void OnStart()
{
matrixf data;
data.Resize(100, 10);
data.Random(0, 100.0);
TSN::MaxMinScaler<float> scaler;
matrixf out;
scaler.FitTransform(data, out);
Print("Scaling complete. Sample value: ", out[0][0]);
}
3. Verify the installation
Run any script from the Test/ folder in the MetaTrader 5 Editor. If no errors appear in the log, you're all set.
Repository Structure
ScalerByLeo/
├── Src/
│ ├── Scaler/
│ │ ├── MinMax/ # MaxMinScaler (CPU) + MaxMinScalerCL (GPU)
│ │ ├── Std/ # StandardizationScaler (CPU) + StandardizationScalerCL (GPU)
│ │ ├── RScaler/ # RobustScaler (CPU) + RobustScalerCL (GPU)
│ │ ├── Bench/ # Internal micro-benchmarks used to pick the fastest patterns
│ │ ├── AllImp.mqh # Single include for all CPU scalers
│ │ └── AllCL.mqh # Single include for all GPU scalers
│ ├── CL/ # OpenCL context/kernel manager
│ └── Kernels/ # OpenCL kernel sources
├── Test/ # Equality tests and benchmarks (CPU vs GPU)
└── Images/ # Repository banner
License
By downloading or using this repository, you accept the license terms.
Requirements
See the dependencies.json file.
Installation of repo code
cd "C:\Users\YOUR USER\AppData\Roaming\MetaQuotes\Terminal\YOUR ID\MQL5\Shared Projects"
tsndep install "https://forge.mql5.io/nique_372/MQLArticles.git"
- Using the
tsndepcommand requires thetsndeppackage (available on PyPI). This command automatically downloads all dependencies and installs every requirement from the repositories. - If any part of the system is private, the install will fail. Contact me so I can grant you access (if it's a product, you can purchase it; if you have any questions, don't hesitate to reach out). Check the dependencies.json file for more info.
Contact
- Platform: MQL5 Community
- Profile: https://www.mql5.com/es/users/nique_372/news
Copyright © 2026 Nique-Leo.