Issues converting send order code from mql4 to mql5
Indeed it can be confusing because Object Name is not the same as Object Type Name.
Object Type is OBJ_RECTANGLE but the individual object name can be "Rectangle_1", "Rectangle_2" and etc.
ObjectGetString(0,name,OBJPROP_TEXT)=="")
You can see here https://www.mql5.com/en/docs/constants/objectconstants/enum_object_property#enum_object_property_string
The name of the object is not the type of the object but the string identifier of the (individual) object name.
You can see this when you look at the ObjectCreate() Function.
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( long chart_id, // chart identifier string name, // object name == "obj_1","obj_2","obj_3"... ENUM_OBJECT type, // object type == OBJ_RECTANGLE sub_window nwin, // window index datetime time1, // time of the first anchor point double price1, // price of the first anchor point ... datetime timeN=0, // time of the N-th anchor point double priceN=0, // price of the N-th anchor point ... datetime time30=0, // time of the 30th anchor point double price30=0 // price of the 30th anchor point );
Look at these two parameters in Yellow.
name = the object name "obj_1" , "obj_2" and etc, this is a different identifier for every OBJ_RECTANGLE on the chart.
type = OBJ_RECTANGLE so this is the object type name, this is the same type name for all OBJ_RECTANGLES on the chart.
So in essence:
ObjectName
The function returns the name of the corresponding object in the specified chart, in the specified subwindow, of the specified type.
string ObjectName( long chart_id, // chart identifier int pos, // number in the list of objects int sub_window=-1, // window index int type=-1 // object type );
It should really be called ObjectType() Function to prevent accidental mixing of these two parameters.

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Below is the method I'm using to place an order after two minutes if it doesn't go through. I've converted the larger part of it from mql4 to mql5 using the documentation on migrating from mql4 to mql5. It's the commented part that I'm not sure how I'll change to mql5 since in mql5 send orders return bool's and not int's. I also realised that the if block:
which was originally
in mql4 doesn't print the if statement. I'm not sure what's preventing it. I guess that's the major issue with my code. I would really appreciate help to get it working. Please see the complete method below: