Hi there.
I have a simple block of code, in MT4, monitoring the mouse move. It helps me to move an object on chart. It is inserted in the void OnChartEvent(const int id,...)
function.
Note that Alerts are for debugging only. (mi_ … are general variables, li_ … are local variables, i is for int, s for string, b for bool and so on). NameMoveBar
is the name of the bar I click on to move the entire object.
OnChartEvent(const int id,...
{
.....................
if(id==CHARTEVENT_MOUSE_MOVE)
{
li_mi_MoveBarXOld = mi_MoveBarX;
li_mi_MoveBarYOld = mi_MoveBarY;
mi_MoveBarX = ObjectGetInteger(0,ms_NameMoveBar,OBJPROP_XDISTANCE,0);
mi_MoveBarY = ObjectGetInteger(0,ms_NameMoveBar,OBJPROP_YDISTANCE,0);
if (li_mi_MoveBarXOld != mi_MoveBarX) lb_BarMove = true;
if (li_mi_MoveBarYOld != mi_MoveBarY) lb_BarMove = true;
Alert ("===========================================");
Alert (id);
Alert (ChartID()," ",mi_MoveBarX," ",mi_MoveBarY);
if (lb_BarMove)
{
lb_Redraw = true;
mb_DrawAllButtons = false; // Used only when moving app on screen
}
}
Normal result is bellow:
My problem is that the very same EA loaded on 2 charts (both GBPUSD on 15 min TF) acts in completely different ways.
On one chart I can move the object on screen and the Alert()
indicates me the new coordinates of the NameMoveBar
object and Alert (id);
gives me “10”, while on the other chart, the same codes gives me no alert.
The if(id==CHARTEVENT_MOUSE_MOVE)
is never TRUE when I am moving the mouse on screen.
If I click & hold on NameMoveBar
I can move it on chart but the if(id==CHARTEVENT_MOUSE_MOVE)
remain false. When I release the object (button acting as move bar) it came back in original position (normally it is drawn in the new mi_MoveBarX
and mi_MoveBarY
positions and the rest of objects are drawn relatively to the new position).
Any clue? My major problem is that it is was working for years, and still working on one chart and not on another, simultaneously && same symbol && same TF.
Thanks in advance!