Can't Move CChartObjectTrend
...
Incorrect handling of events OnChartEvent () in MQL4. Similar code in MQL5 works well.
Is that I am handling the OnChartEvent() in MQL4 incorrectly, or it's a problem with MQL4?
Thanks.
Is that I am handling the OnChartEvent() in MQL4 incorrectly, or it's a problem with MQL4?
Thanks.
Is that I am handling the OnChartEvent() in MQL4 incorrectly, or it's a problem with MQL4?
Thanks.
Hi
Try it.
const long &lparam,
const double &dparam,
const string &sparam)
{
if (sparam == trendLine.Name())
{
// on Drag, want to re-set co-ordinates of trendline.
if (id == CHARTEVENT_OBJECT_DRAG)
{
// get the new co-ordinates
datetime newX = TimeCurrent() - (PeriodSeconds() * 50);
double newY = iOpen(NULL,0,50);
ObjectSetDouble(0,trendLine.Name(),OBJPROP_PRICE1,newY);
ObjectSetInteger(0,trendLine.Name(),OBJPROP_TIME1,newX);
}
}
}
Hi
Try it.
const long &lparam,
const double &dparam,
const string &sparam)
{
if (sparam == trendLine.Name())
{
// on Drag, want to re-set co-ordinates of trendline.
if (id == CHARTEVENT_OBJECT_DRAG)
{
// get the new co-ordinates
datetime newX = TimeCurrent() - (PeriodSeconds() * 50);
double newY = iOpen(NULL,0,50);
ObjectSetDouble(0,trendLine.Name(),OBJPROP_PRICE1,newY);
ObjectSetInteger(0,trendLine.Name(),OBJPROP_TIME1,newX);
}
}
}
Brill - thanks tuoitrecuoi - that worked a treat.
So what's the lesson here? Don't use the the ObjectMove() method?
Hi,
I am trying move a CChartObjectTrend object on the CHARTEVENT_OBJECT_DRAG event, but I am get the error 4202 object does not exist.
Interestingly, if you click the created trend line object after the error message, the code executes fine with no error message.
Please can anyone tell me what I am doing wrong?
Kind regards
Dan.
Output after dragging the the object:
-> ERROR: 4202 object does not exist
Output on a subsequent click of the object:
-> Object Moved