What part of "Object already exists" is unclear? you can only have one object named "HLine"
WHRoeder:
What part of "Object already exists" is unclear? you can only have one object named "HLine"
I know, but the error said, that the object exists, but it does not exist. I checked it in Objects (Ctrl+B).What part of "Object already exists" is unclear? you can only have one object named "HLine"
While the order is a pending order (type 2 or 4), i got true as response to object create but it does not exist! When the order become market order (typ 0), then will the object created but with response false and the error that it already exists.
- fx_maddin: When the order become market order (typ 0), then will the object createdYou created it when you had a pending order (type 2 or 4,) then you again try to create it when it becomes market (type 0)
- Don't hard code constants, use the enumeration Order Properties - Trade Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
WHRoeder:
1. The Plan is, to create this line and it should does not matter which type of order is there. Once again my explanation:- fx_maddin: When the order become market order (typ 0), then will the object createdYou created it when you had a pending order (type 2 or 4,) then you again try to create it when it becomes market (type 0)
- Don't hard code constants, use the enumeration Order Properties - Trade Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
I create a Pending Order. Then, the ObjectCreate function return true, but the object DO NOT EXIST! It is not created!! The Pending Order becomes Market Order, the Object Create function returns false, but the object EXISTS now.
If i create a market order, the object is created instantly.
It sounds crazy and for me it makes no sense, but it is a fact!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
i've the following code sample:
{
//---
/* Check for Open Orders */
for (int cnt = 0; cnt < OrdersTotal(); cnt++) {
if (!OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() == Symbol()) {
if (OrderType() == 0) {
double LinePrice = OrderOpenPrice() + 0.00050;
bool obj = ObjectCreate("HLine", OBJ_HLINE, 0, 0, LinePrice);
if (obj==true) {
Print("Object created");
} else {
Print("Object NOT created. " + IntegerToString(GetLastError()));
}
}
}
}
}
So I changed the code from
There is one more curio in this scenario. If it is a Pending Order, the variable obj returns "true", althought line is not drawn. If order become active, the line is drawn but the variable returns "false" with error code 4200 (Object already exist).
Could anyone help? thanks in advance.