Easily Select Fonts for MT5 Indicators
Info
The Easily Select Fonts for MT5 Indicators is a Library for MetaTrader 5 that when displaying text in metatrader 5 indicators, it's often necessary to allow users to change the font type through the indicator's input parameters. A common approach is to have users manually type the font name.
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Library works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Libraries folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Easily Select Fonts for MT5 Indicators
1. Storage: Place library files in the MQL/Libraries directory to ensure they are accessible to your projects.
2. Implementation: Include the library in your code using the #import directive, ensuring you match the exact function names and parameters.
3. Compilation: Ensure the library is present in the directory before you compile your main EA or script, as the compiler links them during this phase.
4. Management: Keep libraries organized in sub-folders if you manage many custom functions to maintain a clean project structure.
Frequently Asked Questions
Q: What is a library file used for? A: Libraries store reusable code modules, allowing you to centralize common logic used by multiple EAs or indicators.
Q: Is a library executable? A: No, libraries are non-executable files containing functions; they must be imported into an EA, indicator, or script to function.
Q: Can I update a library while the platform is running? A: You should compile your EA or script after updating a library to ensure the latest code changes are integrated.
What this tool does
When displaying text in MetaTrader 5 indicators, it's often necessary to allow users to change the font type through the indicator's input parameters.
Typical Use Case
This Library excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Library works on MetaTrader 5. Place the file in the MQL5/Libraries folder and restart the terminal.
Description & Settings
Related: cselectfile - another powerful library for MetaTrader 5 traders.
When displaying text in MetaTrader 5 indicators, it's often necessary to allow users to change the font type through the indicator's input parameters.Also recommended: selection sort - array sorting algorithm - similar library with strong performance on MetaTrader 5.
A common approach is to have users manually type the font name. However, this method is inconvenient and prone to errors.
A more efficient solution involves using custom variables with a dropdown list. The provided function module facilitates this task.
You only need one example to understand how to use this library.
Consider an indicator (chartinfo_old.mq5) that displays a text label in a corner of the chart. Its input parameters are shown below:
[Image Placeholder: Original Input Parameters]
With this code, the indicator's input parameters window appears as follows:
[Image Placeholder: Indicator Input Parameters Window - Original]
To eliminate the need for users to manually enter font names, implement the following changes:
1. Include the contents of the getfontname.mqh file before the indicator's input parameter declaration using the #include directive.
2. Replace the original fonttype input parameter line with the following:
[Code Placeholder: New Input Parameter Declaration]
This modifies how the variable is used. The value from the previous variable must be assigned to the new string variable, which should be declared at the global level.
Next, replace all instances of the fonttype variable in the indicator code with sfonttype. This change is only required in one location:
[Code Placeholder: Variable Replacement]
Finally, initialize the sfonttype variable within the OnInit() block. This can be accomplished with a few lines of code:
[Code Placeholder: OnInit Initialization]
The revised chartinfo.mq5 indicator can now be compiled.
Observe the changes in the indicator input parameters window:
[Image Placeholder: Indicator Input Parameters Window - Revised]
Working with fonts in indicator input parameters has become significantly more user-friendly.
This solution was developed in 2026.
You may also like: tester benchmark - excellent alternative for library users on MetaTrader 5.
Source Code
#property copyright "robotfx"
#property link "https://robotfx.org"
#property version "1.00"
#property description "this code is educational. feel free to use, modify and upgrade as you wish. visit robotfx.org for professional trading tools"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
#include <getfontname.mqh>
input string text="real"; // text label contents
input color textcolor=red; // text label color
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.