Skip navigation.
Home
Metatrader community - Forex Trading with Metatrader

Object Functions - Part 2

Hi folks,

Today we are going to continue with the remaining of Object Functions and we have a simple MQL program to apply some of what we have learnt about drawing objects programicaly.

Let's see what left of the object functions:

 

ObjectMove:

 

Syntax

bool ObjectMove(string name, int point, datetime time1, double price1)

 Description: 

The ObjectMove function changes the specified coordinate of the object to new x and y coordinate.
Any object has up to 3 coordinates and they are indexed 0, 1 and 2. You specify the coordinate you want to change with its index (point parameter) then set new x and y values for the new coordinate (time1 and time2).
The function returns true if it successfully had changed the coordinate and false otherwise.

Note: If you have a 2 or 3 coordinates object and want to change the 2 or 3 coordinates, you have to use ObjectMove function 2 or 3 times for every coordinate.

Parameters:

string name:

The string name of the object you want to change its coordinate.

int point:

Coordinate index (0, 1, 2) you want to change it.

datetime time1:

The first vertical coordinate of the object. This parameter is a datetime type (because the vertical coordinate of the chart is the time coordinate).

double price1:

The first horizontal coordinate of the object. This parameter is a double type (because the horizontal coordinate of the chart is the price coordinate).
 

Note: You have to note which currency pair you are going to draw on its chart because the prices ranges differs from currency to currency.

 Example

ObjectMove("MyTrend", 1, D'2005.02.25 12:30', 1.2345);

 

ObjectName:

 

Syntax

string ObjectName(int index)

 Description: 

The ObjectName function returns the object name for the given index from the object list. To check the error use GetLastError() function.

Parameters:

int index:

The index of the object you want to get its name.

Note: The index must be equal to 0 or greater, and be less than the total of the objects count returned by ObjectsTotal() function.

 Example

int obj_total=ObjectsTotal();
string name;
for(int i=0;i<obj_total;i++)
{
name=ObjectName(i);
Print(i,"Object name is " + name);
}