This has me baffled. I'm drawing a horizontal line on my chart, and allowing the user to select and drag it to vary a value. I'm handling a CHARTEVENT_OBJECT_DRAG event, and the object is recognized, raises the event, and passes the name of the object in the sparam. But when I do an "ObjectGetDouble(0, objectName, OBJPROP_PRICE, 0, propertyValue)", it's returning false (failure), the propertyValue remains 0.0, and GetLastError() reports 4202 (ERR_OBJECT_DOES_NOT_EXIST).
How can it exist and raise and event, but not exist when I try to get its property?
This has me baffled. I'm drawing a horizontal line on my chart, and allowing the user to select and drag it to vary a value. I'm handling a CHARTEVENT_OBJECT_DRAG event, and the object is recognized, raises the event, and passes the name of the object in the sparam. But when I do an "ObjectGetDouble(0, objectName, OBJPROP_PRICE, 0, propertyValue)", it's returning false (failure), the propertyValue remains 0.0, and GetLastError() reports 4202 (ERR_OBJECT_DOES_NOT_EXIST).
How can it exist and raise and event, but not exist when I try to get its property?
Please show code to reproduce your problem.
Here's the code:
void OnChartEvent(const int id,const long& lparam,const double& dparam,const string& sparam)
{
if(id == CHARTEVENT_OBJECT_DRAG && sparam == baseLineName)
{
ResetLastError();
long currentChart = ChartID();
double lineValue;
bool success = ObjectGetDouble(0, baseLineName, OBJPROP_PRICE, 0, lineValue);
if(!success)
{
int lastError = GetLastError();
Alert("ObjectGetDouble() [", baseLineName,"] failed: ", ErrorDescription(lastError), " (", lastError, ")");
return;
}
I do some other things with lineValue after that code, but the error has occurred by the "if (!success)" block.
Thanks for your help.
Here's the code:
I do some other things with lineValue after that code, but the error has occurred by the "if (!success)" block.
Thanks for your help.
Hello Daveh,
instead of using CHARTEVENT_OBJECT_DRAG I suggest you to use CHARTEVENT_OBJECT_CLICK...
Something like this:
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- if(id==CHARTEVENT_OBJECT_CLICK) { string ClickedChartObject=sparam; Print("You clicked on the object named '"+sparam+"'"); //--- if(ClickedChartObject == "baseLineName") Print("Object price = "+ObjectGetDouble(0, "baseLineName", OBJPROP_PRICE, 0)); //--- ChartRedraw(); }
I hope it helps you somehow.
Hello Daveh,
instead of using CHARTEVENT_OBJECT_DRAG I suggest you to use CHARTEVENT_OBJECT_CLICK...
Something like this:
I hope it helps you somehow.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This has me baffled. I'm drawing a horizontal line on my chart, and allowing the user to select and drag it to vary a value. I'm handling a CHARTEVENT_OBJECT_DRAG event, and the object is recognized, raises the event, and passes the name of the object in the sparam. But when I do an "ObjectGetDouble(0, objectName, OBJPROP_PRICE, 0, propertyValue)", it's returning false (failure), the propertyValue remains 0.0, and GetLastError() reports 4202 (ERR_OBJECT_DOES_NOT_EXIST).
How can it exist and raise and event, but not exist when I try to get its property?