MQL4 TUTORIAL EXAMPLES – THE COMMENT COMMAND

The “Comment” command in MQL4 is a useful tool for traders who want to display text on the chart. This command is used to add annotations or descriptions to the chart, making it easier to understand what is happening at any given moment. In this article, we will go over the basics of the “Comment” command and show you how to use it to display the local time on the chart.

The syntax for the “Comment” command is simple. You just need to include the text that you want to display within the parentheses, like this:

 

Comment(“Hello, World!”);

 

This will display the text “Hello, World!” on the chart. However, this is just a basic example. You can use the “Comment” command to display a variety of information, such as the local time. Here’s an example of how to display the local time on the chart:

 

Comment(“The current time is: ” + TimeToString(TimeLocal()));

 

The “TimeLocal” function is used to get the local time, and the “TimeToString” function is used to convert the time from a numerical value to a string that can be displayed on the chart. When you run this code, you will see the local time displayed on the chart.

In conclusion, the “Comment” command in MQL4 is a useful tool for traders who want to add annotations and descriptions to their charts. It is simple to use and can be used to display a variety of information, such as the local time. By using the “Comment” command, you can make your charts more informative and easier to understand.