Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

Metatrader 5 Libraries | Advanced Risk Manager: Auto Suffix Detection Multi Currency Lot Sizer | MQL5 Release

New free code from MQL5: indicators, EAs, and scripts for traders.

Purpose of the File

This professional MQL5 include file (.mqh) is engineered as a reusable, self-contained component designed specifically for advanced risk management and precise position sizing across diverse trading assets.

The Underlying Strategy and Core Concept

Many commercial Expert Advisors fail unexpectedly when deployed on trading accounts with non-USD base currencies (such as EUR, GBP, or JPY) or when trading under brokers that append custom suffixes (e.g., .pro, .ecn) to asset symbols. This library solves these multi-broker infrastructure issues by introducing a dynamic exchange rate engine that ensures deterministic risk calculations under any market environment.

The core architecture utilizes a high-performance triangular currency conversion algorithm to map the profit currency of the target asset directly to the trader's account currency. By scanning direct, inverse, and USD cross-pairs in fractions of a millisecond, the module calculates the exact current tick value, completely eliminating the risk of over-leveraging due to currency mismatches.


Image for Advanced Risk Manager: Auto Suffix Detection  Multi Currency Lot Sizer

Trade Renko charts automatically using the advanced Renko Expert Advisors. Clean trends, better entries. Discover them here.


Key Architecture Components and Methods

- CalculateLotSize: Dynamically computes the deterministic volume size based on a strict user-defined risk percentage of the account balance and the exact stop-loss distance.
- GetConversionRate: Automatically resolves exchange rate conversion paths, switching between direct asset evaluation and triangular cross-currency calculations.
- ExtractSuffix: Programmatically identifies and strips broker-specific naming extensions to prevent "Symbol Not Found" errors during server lookup processes.
- CheckDrawdownLimit: Provides enterprise-grade capital protection by evaluating real-time equity drawdown and preventing new executions if safety limits are breached.

How to Integrate

To deploy this module, simply place the file inside your MQL5\Include\ directory, include the header at the top of your Expert Advisor, and instantiate the class object. Initialize the framework in your OnInit() handler and invoke the lot sizing algorithm immediately prior to constructing your trade requests.

Complement community code with advanced automation from RobotFX.

75441

Best MetaTrader Indicators + Profitable Expert Advisors