Some graphical objects are built using multiple levels (repetitive lines). These include:
MQL5 allows you to set level properties for such objects. The properties include their number, colors, values, and labels.
Identifier |
Description |
Type |
|---|---|---|
OBJPROP_LEVELS |
Number of levels |
int |
OBJPROP_LEVELCOLOR |
Level line color |
color |
OBJPROP_LEVELSTYLE |
Level line style |
ENUM_LINE_STYLE |
OBJPROP_LEVELWIDTH |
Level line width |
int |
OBJPROP_LEVELTEXT |
Level description |
string |
OBJPROP_LEVELVALUE |
Level value |
double |
When calling the ObjectGet and ObjectSet functions for all properties except OBJPROP_LEVELS, it is required to provide an additional modifier parameter with the number of a specific level.
As an example, let's consider the indicator ObjectHighLowFibo.mq5. For a given range of bars, which is defined as the number of the last bar (baroffset) and the number of bars (BarCount) to the left of it, the indicator finds the High and Low prices and then creates the OBJ_FIBO object for these points. As new bars form, Fibonacci levels will shift to the right to more current prices.
#property indicator_chart_window
|
The direct setting of the object is done in the auxiliary function DrawFibo. In it, in particular, the levels are painted in rainbow colors, and their style and thickness are determined based on whether the corresponding values are "round" (without a fractional part).
bool DrawFibo(const string name, const datetime &t[], const double &p[],
|
Here is a variant of what an object might look like on a chart.

Fibonacci object with level settings