Discussing the article: "Automating Trading Strategies in MQL5 (Part 11): Developing a Multi-Level Grid Trading System"

 

Check out the new article: Automating Trading Strategies in MQL5 (Part 11): Developing a Multi-Level Grid Trading System.

In this article, we develop a multi-level grid trading system EA using MQL5, focusing on the architecture and algorithm design behind grid trading strategies. We explore the implementation of multi-layered grid logic and risk management techniques to handle varying market conditions. Finally, we provide detailed explanations and practical tips to guide you through building, testing, and refining the automated trading system.

A multi-level grid trading system is a structured approach that capitalizes on market volatility by placing a series of buy and sell orders at predetermined intervals across a range of price levels. This strategy we're about to implement isn’t about predicting the market’s direction but rather about profiting from the natural flow of prices, capturing gains whether the market moves up, down, or sideways.

Building on this concept, our program will implement the multi-level grid strategy through a modular design that separates signal detection, order execution, and risk management. In our system development, we will first initialize key parameters—such as moving averages for identifying trade signals—and set up a basket structure that encapsulates trade details like initial lot sizes, grid spacing, and take-profit levels.

As the market evolves, the program will monitor price movements to trigger new trades and manage existing positions, adding orders at each grid level based on predefined conditions and dynamically adjusting risk parameters. The architecture also will include functions for recalculating break-even points, modifying take-profit targets, and closing positions when profit targets or risk thresholds are met. This structured plan will not only organize the program into distinct, manageable components but also ensure that every layer of the grid contributes to a cohesive, risk-managed trading strategy ready for robust backtesting and trading deployment. In a nutshell, this is what the architecture will look like.

GRIDS ARCHITECTURE

Author: Allan Munene Mutiiria

 

A very good code and very fast EA!

Unfortunately there is a problem with the lot size calculation - multipliers with a decimal (like 1.3, 1.5 etc) may cause trouble with MQL order functions as the lot size gives sometimes  error codes 4756 when the multiplier is not 1 oder 2.

It would be too nice if the lot size calculation could be changed marginally to ensure that lot sizes are appropriately calculated for feeding into the order functions for all multiplier values.

 
johnsteed #:

A very good code and very fast EA!

Unfortunately there is a problem with the lot size calculation - multipliers with a decimal (like 1.3, 1.5 etc) may cause trouble with MQL order functions as the lot size gives sometimes  error codes 4756 when the multiplier is not 1 oder 2.

It would be too nice if the lot size calculation could be changed marginally to ensure that lot sizes are appropriately calculated for feeding into the order functions for all multiplier values.

Thanks for the kind feedback. Sure.

 

Hi,

After reading the article, found it useful and will definitely testing it out. However, seem I am not seeing or perhaps I missed out from the article on the seperation of first position TP which I believe it is also useful and sustainable for the trading strategy.


Thank You.

 
cbkiri #:

Hi,

After reading the article, found it useful and will definitely testing it out. However, seem I am not seeing or perhaps I missed out from the article on the seperation of first position TP which I believe it is also useful and sustainable for the trading strategy.


Thank You.

Sure. Thanks.