- ObjectCreate
- ObjectName
- ObjectDelete
- ObjectsDeleteAll
- ObjectFind
- ObjectGetTimeByValue
- ObjectGetValueByTime
- ObjectMove
- ObjectsTotal
- ObjectSetDouble
- ObjectSetInteger
- ObjectSetString
- ObjectGetDouble
- ObjectGetInteger
- ObjectGetString
- TextSetFont
- TextOut
- TextGetSize
ObjectCreate
The function creates an object with the specified name, type, and the initial coordinates in the specified chart subwindow. During creation up to 30 coordinates can be specified.
bool ObjectCreate(
|
Parameters
chart_id
[in] Chart identifier. 0 means the current chart.
name
[in] Name of the object. The name must be unique within a chart, including its subwindows.
type
[in] Object type. The value can be one of the values of the ENUM_OBJECT enumeration.
sub_window
[in] Number of the chart subwindow. 0 means the main chart window. The specified subwindow must exist, otherwise the function returns false.
time1
[in] The time coordinate of the first anchor.
price1
[in] The price coordinate of the first anchor point.
timeN=0
[in] The time coordinate of the N-th anchor point.
priceN=0
[in] The price coordinate of the N-th anchor point.
time30=0
[in] The time coordinate of the thirtieth anchor point.
price30=0
[in] The price coordinate of the thirtieth anchor point.
Return Value
The function returns true if the command has been successfully added to the queue of the specified chart, or false otherwise. If an object has already been created, an attempt is made to change its coordinates.
Note
An asynchronous call is always used for ObjectCreate(), that is why the function only returns the results of adding the command to a chart queue. In this case, true only means that the command has been successfully enqueued, but the result of its execution is unknown.
To check the command execution result, you can use the ObjectFind() function or any other function that requests object properties, such as ObjectGetXXX. However, you should keep in mind that such functions are added to the end of the queue of that chart, and they wait for the execution result (due to the synchronous call), and can therefore be time consuming. This feature should be taken into account when working with a large number of objects on a chart.
An object name should not exceed 63 characters.
The numbering of the chart subwindows (if there are subwindows with indicators in the chart) starts with 1. The main chart window of the chart is and always has index 0.
The large number of anchor points (up to 30) is implemented for future use. At the same time, the limit of 30 possible anchor points for graphical objects is determined by the limit on the number of parameters (not more than 64) that can be used when calling a function.
When an object is renamed, two events are formed simultaneously. These events can be handled in an Expert Advisor or indicator by the OnChartEvent() function:
- an event of deletion of an object with the old name;
- an event of creation of an object with a new name.
There is a certain number of anchor points that must be specified when creating each object type:
ID |
Description |
Anchor Points |
---|---|---|
Vertical Line |
One anchor point. Actually only the time coordinate is used. |
|
Horizontal Line |
One anchor point. Actually only the price coordinate is used. |
|
Trend Line |
Two anchor points. |
|
Trend Line By Angle |
Two anchor points. |
|
Cycle Lines |
Two anchor points. |
|
Arrowed Line |
Two anchor points. |
|
Equidistant Channel |
Three anchor points. |
|
Standard Deviation Channel |
Two anchor points. |
|
Linear Regression Channel |
Two anchor points. |
|
Andrews’ Pitchfork |
Three anchor points. |
|
Gann Line |
Two anchor points. |
|
Gann Fan |
Two anchor points. |
|
Gann Grid |
Two anchor points. |
|
Fibonacci Retracement |
Two anchor points. |
|
Fibonacci Time Zones |
Two anchor points. |
|
Fibonacci Fan |
Two anchor points. |
|
Fibonacci Arcs |
Two anchor points. |
|
Fibonacci Channel |
Three anchor points. |
|
Fibonacci Expansion |
Three anchor points. |
|
Elliott Motive Wave |
Five anchor points. |
|
Elliott Correction Wave |
Three anchor points. |
|
Rectangle |
Two anchor points. |
|
Triangle |
Three anchor points. |
|
Ellipse |
Three anchor points. |
|
Thumbs Up |
One anchor point. |
|
Thumbs Down |
One anchor point. |
|
Arrow Up |
One anchor point. |
|
Arrow Down |
One anchor point. |
|
Stop Sign |
One anchor point. |
|
Check Sign |
One anchor point. |
|
Left Price Label |
One anchor point. |
|
Right Price Label |
One anchor point. |
|
Buy Sign |
One anchor point. |
|
Sell Sign |
One anchor point. |
|
Arrow |
One anchor point. |
|
Text |
One anchor point. |
|
Label |
Position is set using the OBJPROP_XDISTANCE and OBJPROP_YDISTANCE properties. |
|
Button |
Position is set using the OBJPROP_XDISTANCE and OBJPROP_YDISTANCE properties. |
|
Chart |
Position is set using the OBJPROP_XDISTANCE and OBJPROP_YDISTANCE properties. |
|
Bitmap |
One anchor point. |
|
Bitmap Label |
Position is set using the OBJPROP_XDISTANCE and OBJPROP_YDISTANCE properties. |
|
Edit |
Position is set using the OBJPROP_XDISTANCE and OBJPROP_YDISTANCE properties. |
|
The "Event" object corresponding to an event in the economic calendar |
One anchor point. Actually only the time coordinate is used. |
|
The "Rectangle label" object for creating and designing the custom graphical interface. |
Position is set using the OBJPROP_XDISTANCE and OBJPROP_YDISTANCE properties. |