mytradertools :
Incorrect handling of events OnChartEvent () in MQL4. Similar code in MQL5 works well.
...
barabashkakvn:
Incorrect handling of events OnChartEvent () in MQL4. Similar code in MQL5 works well.
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.
mytradertools:
Problem with MQL4.
Is that I am handling the OnChartEvent() in MQL4 incorrectly, or it's a problem with MQL4?
Thanks.
mytradertools:
Is that I am handling the OnChartEvent() in MQL4 incorrectly, or it's a problem with MQL4?
Thanks.
Hi
Try it.
void OnChartEvent(const int id,
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);
}
}
}
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);
}
}
}
tuoitrecuoi:
Hi
Try it.
void OnChartEvent(const int id,
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);
}
}
}
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?
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
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