- Functions for getting the basic properties of the current chart
- Chart identification
- Getting the list of charts
- Getting the symbol and timeframe of an arbitrary chart
- Overview of functions for working with the complete set of properties
- Descriptive chart properties
- Checking the status of the main window
- Getting the number and visibility of windows/subwindows
- Chart display modes
- Managing the visibility of chart elements
- Horizontal shifts
- Horizontal scale (by time)
- Vertical scale (by price and indicator readings)
- Colors
- Mouse and keyboard control
- Undocking chart window
- Getting MQL program drop coordinates on a chart
- Translation of screen coordinates to time/price and vice versa
- Scrolling charts along the time axis
- Chart redraw request
- Switching symbol and timeframe
- Managing indicators on the chart
- Opening and closing charts
- Working with tpl chart templates
- Saving a chart image
Functions for getting the basic properties of the current chart
In many examples in the book, we have already had to use Predefined Variables, containing the main properties of the chart and its working symbol. MQL programs also have access to functions that return the values of some of these variables. It does not matter what is used, a variable or a function, and thus you can use your preferred source code styles.
Each chart is characterized by a working symbol and timeframe. They can be found using the Symbol and Period functions, respectively. In addition, MQL5 provides simplified access to the two most commonly used symbol properties: price point size (Point) and the associated number of significant digits (Digits) after the decimal point in the price.
string Symbol()
The Symbol function returns the symbol name of the current chart, i.e. the value of the system variable _Symbol. To get the symbol of an arbitrary chart, there is the ChartSymbol function which operates based on the chart identifier. We will discuss the methods for obtaining chart identifiers a little later.
ENUM_TIMEFRAMES Period()
The Period function returns the timeframe value (ENUM_TIMEFRAMES) of the current chart, which corresponds to the _Period variable. To get the timeframe of an arbitrary chart, use the function ChartPeriod, and it also needs an identifier as a parameter.
double Point()
The Point function returns the point size of the current instrument in the quote currency, which is the same as the value of the _Point variable.
int Digits()
The function returns the number of decimal places after the decimal point, which determines the accuracy of measuring the price of the symbol of the current chart, which is equivalent to the variable _Digits.
Other properties of the current tool allow you to get SymbolInfo-functions, which in a more general case provide an analysis of all instruments.
The following simple example of the script ChartMainProperties.mq5 logs the properties described in this section.
void OnStart()
|
For the EURUSD,H1 chart, we will get the following log entries.
_Symbol=EURUSD / ok
|