CHARTEVENT_MOUSE_MOVE randomly not working

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!

To make it simpler I’ve written a 4 lines EA obtaining the same behavior:

int OnInit() {EventSetTimer(1);return(INIT_SUCCEEDED);}
void OnDeinit(const int reason)   {EventKillTimer();}
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)   
{if(id==CHARTEVENT_MOUSE_MOVE) Alert (id," ",TimeLocal());}

On one chart (GBPUSD 15 min) when I move the mouse on screen I get the Alert on screen: “10” and the local time.
On the next chart (GBPUSD 15 min), when moving the mouse I get NO Alert.
if(id==CHARTEVENT_MOUSE_MOVE) is always false.
Thank you so much for any clues.
Best,
Nicolae

You enable mouse events tracking in OnInit()?

  {
           //--- Enable tracking of mouse events
           ChartSetInteger(0,CHART_EVENT_MOUSE_MOVE,true);
            ...
  }
3 Likes

No, I didn’t.
Thank you so much. It looks to be a very good practice that I’ve completely ignored.
I’ll enable the tracking of mouse event and see if the described behavior will repeat.
Have a wonderful day,
Nicolae