Draw Horizontal Line Bar in MQL Programming Language
MQL, or MetaQuotes Language, is a high-level programming language used for developing technical indicators, trading robots, and utility applications on the MetaTrader platform. In this article, we will discuss how to draw a horizontal line bar in MQL programming language, which can be useful for traders who want to mark certain timeframes or price levels on their charts.
Key Concepts
To draw a horizontal line bar in MQL, we need to use the ObjectCreate function, which creates a graphical object on the chart. The function takes several parameters, including the object type, name, and properties. In this case, we will use the OBJ_HLINE object type to create a horizontal line.
To set the position of the horizontal line, we need to use the ObjectSet function, which modifies the properties of an existing graphical object. The function takes several parameters, including the object name, property, and value. In this case, we will use the PRICE property to set the price level of the horizontal line.
Applications
Drawing horizontal line bars in MQL can be useful for traders who want to mark important price levels or timeframes on their charts. For example, a trader may want to draw a horizontal line bar at the previous day's high or low to monitor price action relative to those levels. Alternatively, a trader may want to draw a horizontal line bar at a certain time of day to monitor price action during specific trading sessions.
Significance
Drawing horizontal line bars in MQL can help traders to better understand price action and make more informed trading decisions. By marking important price levels or timeframes on their charts, traders can quickly identify potential support and resistance levels, breakouts, and trend reversals. Additionally, drawing horizontal line bars can help traders to stay focused on their trading strategy and avoid emotional decision-making.
Code Example
Here is an example of how to draw a horizontal line bar in MQL programming language:
// create a horizontal line object
int obj_id = ObjectCreate(0, "My Horizontal Line", OBJ_HLINE);
// set the price level of the horizontal line
ObjectSet(obj_id, PRICE, 1.2345);
// set the color of the horizontal line
ObjectSet(obj_id, COLOR, clrRed);
// set the width of the horizontal line
ObjectSet(obj_id, WIDTH, 2);
// set the style of the horizontal line
ObjectSet(obj_id, STYLE, STYLE_SOLID);
- MQL is a high-level programming language used for developing technical indicators, trading robots, and utility applications on the MetaTrader platform.
- To draw a horizontal line bar in MQL, we need to use the
ObjectCreateandObjectSetfunctions. - Drawing horizontal line bars can be useful for marking important price levels or timeframes on charts, and can help traders to make more informed trading decisions.