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
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
❀92πŸ‘7⚑4😁2πŸ‘€2