MQL5 Algo Trading
489K subscribers
3.1K photos
3.1K links
The best publications of the largest community of algotraders.

Subscribe to stay up-to-date with modern technologies and trading programs development.
Download Telegram
Statistical arbitrage frameworks are evolving for retail traders, focusing on probabilistic rather than historical market notions. By leveraging statistical methods like cointegration, relationships between diverse assets can be identified and traded. The challenge remains in the stability of these relationships over time, necessitating continuous monitoring and adjustments in portfolio weights.

Implementing techniques like In-Sample/Out-of-Sample ADF validation and Rolling Windows Eigenvector Comparison enhance detection and assessment of asset relationships. These methods fine-tune portfolio management and risk analysis.

Our scripted automation aids backtesting these strategies, highlighting adjustments needed for optimal real-time trading execution. Emphasis is placed on dynamic updates of portfolio weights using tested parameters, ensuring that ...

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL5 #MT5 #Algorithm
❀31πŸ‘Œ3😐1
Explore the next level of trading with our MQL5-based solution for dynamic support and resistance zones. This algorithm identifies these zones by analyzing market data in real-time, adapting as market conditions change. By transforming static lines into probability zones, it enhances trade execution and reduces uncertainty. Our approach integrates historical price analysis, identifying and marking extreme and average price reactions to reflect realistic market behavior. This innovative system allows traders to leverage consistent patterns while minimizing emotional trading decisions. Implemented through a tailored MQL5 indicator, it enables precise, real-time analysis, promising more informed and strategic decision-making for developers and traders alike.

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #Algorithm
❀76πŸ‘Œ3😁2🀣2⚑1
When evaluating the functionality of CopyTicksRange(), several challenges were identified with managing millisecond precision. Originally, the intention was to utilize CDateTime for its flexibility in adjusting time units through increment and decrement methods. However, translating milliseconds (ulong format as seconds since 1 January 1970 multiplied by 1000) proved difficult, as milliseconds alone do not convey precise dates. Utilizing CDateTime or TimeStruct allows for easy manipulation of time units, though the format can become disjointed and unclear.

To address this, a new CDateTimeMsc class was developed. This class, essentially a structure under Structures/Classes, inherits from the prior format and extends functionality to integrate milliseconds when precise times are needed. Furthermore, methods for incrementing and decrementing have been ad...

πŸ‘‰ Read | AppStore | @mql5dev

#MQL5 #MT5 #Algorithm
❀27πŸ”₯3πŸ‘Œ3⚑2πŸ‘1
The article expands the DoEasy library for MetaTrader 5 by enhancing support for graphical objects. It introduces new library classes for shapes, arrows, and other graphical elements, allowing them to be added to collections. The update also corrects a spelling error across library files and refines how graphical objects' properties are handled, particularly with anchor points. The article outlines improved methods for identifying and managing newly added graphical objects by storing them in a structured list, enhancing memory management, and preventing leaks. Developers can now efficiently track, sort, and integrate graphical objects within the trading terminal, providing enhanced chart management capabilities.

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #Algorithm
❀60😁4⚑2πŸ†1
Concept development for improving library classes and defining descendant objects for graphical representation is underway. The focus is on expanding the abstract graphical object class by incorporating specific characteristics for objects in lines, channels, Gann, Fibo, and Elliott groups. This approach ensures that each descendant class highlights its unique properties while aligning with the overall structure of the abstract class.

Enhancements include adding a grouping property to the object class and improving time frame visibility functionality. This allows for more granular control over object properties, facilitating better management and manipulation within the library. Concrete examples involve the creation of classes for specific graphical object types, each with dedicated methods for handling associated properties.

These improvements aim to...

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL5 #MT5 #Algorithm
❀58πŸ‘Œ6πŸ‘€5⚑1
A mathematical approach to fractals reveals essential principles for model building. The article outlines developing an initial formula for fractals, suggesting that fractal-related values can be represented by a mathematical model applied in algorithmic trading systems. It describes symmetric and asymmetric corridors, highlighting the average step calculation for each. Symmetry simplifies to \(S=n^2\), while asymmetry involves distinct steps in each half of the corridor. A generalized formula for average steps considers probability deviations.

Further refinement of fractal calculations utilizes a prototype power function, allowing testing of mathematical assumptions. Techniques for evaluating function prototypes and verifying results are elaborated upon. Through this structured analysis, a deeper understanding of fractal geometry is achieved, aiding ...

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #Algorithm
❀60πŸ€”5πŸ‘Œ5πŸŽ‰4
The Billiards Optimization Algorithm (BOA), introduced by Hadi Givi and Marie HubΓ‘lovskΓ‘ in 2023, offers a unique approach to solving optimization problems by drawing inspiration from billiards. It models the search space as a pool table with solutions represented as balls moving towards optimal pockets. The iterative refinement process aims to balance global and local search using a stochastic method.

Implementation details reveal a method influenced by a combination of random and deterministic movement, guided by an equation that adjusts positions based on the proximity to target pockets. The algorithm runs through multiple iterations to refine solutions and approach optimality.

Initial test results suggested room for improvement, particularly in navigating large-dimensional problems or avoiding local minima. Revising the movement equation for...

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #Algorithm
❀54✍6πŸ”₯6🀨5πŸ‘Œ4πŸ‘3
Enhancing the library classes involves optimizing existing code to improve readability and reduce redundancy by formalizing repetitive logic into functions or methods. This approach streamlines code management, ensuring a cleaner and more efficient structure.

The addition of a geometric animation frame object class enables easier construction of regular polygons by calculating their vertex coordinates using geometric equations, improving precision and reducing manual calculations.

Adjustments have been made to accommodate geometric shapes, including changes in animation frame naming conventions and the addition of new enumeration types for geometric animations. This ensures consistent handling of all animation frames regardless of their shape or type.

Geometric animation frames now facilitate inserting regular polygons into circumscribed circles, e...

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL5 #MT5 #Algorithm
❀83πŸ‘13πŸ‘Œ6πŸ‘€4πŸ’”3🀯1
Explore the next phase of algorithmic trading with MetaTrader 5 as we enhance support and resistance zones with decision-making intelligence. Building on earlier work, we're shifting from passive analysis to active decision making. The focus is on programmable entry logic using candlestick patterns within specific zones, vital for precise trading in smaller accounts. Automating detection and notifications ensures traders capture every opportunity efficiently. We present a modular system leveraging MQL5 for real-time alerts, zone-awareness, and advanced candlestick detection. This innovation paves the way for future automated solutions, offering both traders and developers a robust framework to refine and execute trading strategies.

πŸ‘‰ Read | Freelance | @mql5dev

#MQL5 #MT5 #Algorithm
❀94πŸ‘Œ7πŸ‘4πŸ’―2✍1
The Successful Restaurateur Algorithm (SRA) offers a unique approach to optimization by focusing on improvement rather than elimination. Unlike traditional methods, SRA enhances weaker solutions by integrating successful elements from better ones, maintaining diversity and steady improvement.

The implementation involves a main loop that selects the least successful "dish," combines it with elements from the best, and evaluates the new solutions. Parameters like temperature and innovation rate control experimentation intensity, balancing exploration and refinement.

Tests show SRA's broad search capabilities but highlight its challenges in precise solution refinement, ranking it 20th among population optimization algorithms. Despite mixed results, SRA's distinctive strategy provides valuable insights for future algorithm development.

πŸ‘‰ Read | AppStore | @mql5dev

#MQL5 #MT5 #Algorithm
❀64πŸ”₯7πŸ†6⚑5🀨5πŸ‘€3✍2
Neuroboids Optimization Algorithm (NOA) reframes population-based optimization as many tiny neural agents. Each β€œneuroboid” is a minimal two-layer network trained with Adam, using the current best candidate as a moving target rather than hard-coded swarm rules.

The loop is straightforward: random initialization, per-agent forward pass to propose a step, error vs. the best solution, backprop updates, then position updates with scaling to [-1, 1] and bounded resampling. A small elite-copy probability adds controlled exploitation while preserving diversity.

In benchmark tests (Hilly, Forest, Megacity), NOA reached about 45% of the maximum aggregated score for small to moderate dimensions, but becomes too slow at very high dimensionality (e.g., 1000 variables). Visual runs show fan-like movement patterns that reflect learned search directions across age...

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #algorithm
❀25πŸ‘6πŸ‘Œ2πŸ”₯1
Part 11 builds a MetaTrader 5 correlation matrix dashboard to quantify cross-asset relationships for portfolio design, hedging, and multi-symbol strategies. It supports Pearson (linear), Spearman (rank-based), and Kendall (order agreement), all computed on price deltas over a selectable timeframe and bar count.

Two visual modes are implemented: a standard grid using configurable thresholds plus p-value β€œstars” for statistical confidence, and a heatmap using color interpolation to reveal subtle correlation differences.

The MQL5 design emphasizes extensibility: symbol-list parsing with Market Watch validation, matrices for correlations and p-values, reusable CDF-based p-value functions, and event-driven UI controls for timeframe and mode switching with automatic refresh on new data.

πŸ‘‰ Read | Signals | @mql5dev

#MQL5 #MT5 #algorithm
❀28⚑4πŸ‘Œ1
GUI animation on CCanvas requires deterministic redraw. Overpainting frames accumulates pixels, so state must be restored before drawing the next frame.

A minimal sprite workflow is implemented by caching the background under a moving element, drawing the element, then restoring the cached pixels on the next update. This scales better than full form redraw for multiple independent elements.

GCnvElement is extended to store an initial pixel snapshot, add resource-to-array copying, and track last text coordinates plus anchor-based X/Y offsets for correct background capture.

ShadowObj is simplified by reusing the new base snapshot and Width/Height accessors. Form.mqh adds a pixel-copier class with ID-based instances, storing rect coordinates, effective clipped size, and save/restore methods for partial canvas regions.

πŸ‘‰ Read | Calendar | @mql5dev

#MQL5 #MT5 #algorithm
❀67πŸ‘Œ11
Work continues on structural templates and type overloading, moving from basic structs toward data-aware containers used in search and lookup tasks.

The example models a key/value association using two arrays (K as keys, H as values). A direct index access fails when K is unordered, so the relationship must be preserved while enabling efficient search via sorting or binary search.

A refined approach embeds the lookup inside a struct: search K for a key, then return H at the same position. This keeps the mapping intact and prepares the code for reuse.

Generalization then starts by templating one base type to trigger compiler overloading. This introduces warnings when return types and stored types diverge, highlighting a common library-design risk: hidden conversions and mismatched expectations.

πŸ‘‰ Read | Calendar | @mql5dev

#MQL5 #MT5 #algorithm
❀67πŸ‘Œ4😱3πŸ‘1😁1
Structured vs organized code remains a frequent source of confusion. A practical boundary appears when structures start carrying context through internal procedures, before transitioning to classes and OOP.

A struct with public data can compute average/median, but it also allows external writes. After a reset, memory may be reused incorrectly, producing wrong medians and hard-to-trace faults. This is a typical encapsulation error.

Marking internal arrays as private blocks direct access and even prevents blanket memory wipes, forcing explicit API methods for set/reset/print. The result is tighter invariants, clearer intent, and fewer hidden state bugs, at the cost of more deliberate design.

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #algorithm
❀30πŸ‘Œ2
Part 41 shifts from writing trade journals to reading them back in MQL5, using a practical target: an indicator that ingests a CSV trading history and plots a balance curve from profit/loss over a selected period.

The core technique is treating CSV content as sequential elements (cell-like values), not β€œlines of text”. The workflow starts by opening the file in FILE_READ with CSV parsing and defined encoding, validating the handle, and using FileIsEnding + incremental reads to count total elements for safe loop bounds.

After counting, the file pointer is reset, then all elements are loaded into dynamic arrays. This enables scalable grouping by column (TradeID, LotSize, etc.), avoids fixed-size structures, and prevents out-of-range errors when processing real trading logs.

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #Algorithm
❀28⚑5πŸ‘Œ3
ALGLIB’s MQL5 port ships minLBFGS but lacks a box-constrained variant, pushing developers toward heavier optimizers for simple bound-limited calibration tasks. A compact Truncated Newton Conjugate-Gradient (TNC) solver fills that gap with an API designed to drop into projects like minLBFGS.

TNC approximates Newton steps using an inner Conjugate Gradient loop, relying on Hessian-vector products derived from gradient finite differences instead of forming a full Hessian. It supports analytic gradients when available, plus stable numerical differentiation near bounds, while enforcing constraints via projection and variable clamping.

The implementation is packaged as tnc.mqh with a CFunctor/CTruncNewtonCG interface, tunable stopping criteria, and clear termination codes. It’s validated on Rosenbrock and used to fit logistic regression alongside LBFGS, pro...

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL5 #MT5 #algorithm
❀93πŸ‘7⚑4😁2πŸ‘€2