Trade level drag event

 

I'm looking to detect event of dragging trade level WHILE dragging. I have written indicator replacing standard trade levels with custom HLINES. I do imitate level dragging by using attached code, but the solution is not elegant, takes more resources than necessary and triggers on every mouse move with button clicked, not only on trade level drag. I would appreciate if someone comes up with a better idea.

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   if(showLevelOnDrag && id==CHARTEVENT_MOUSE_MOVE && MathMod(StringToInteger(sparam),2)>0)
     {
      int      x     =(int)lparam;
      int      y     =(int)dparam;
      datetime time=0;
      double   price=0;
      int      window=0;
      ChartXYToTimePrice(0,x,y,window,time,price);
      CreateLine(9999999999999999,LEVEL_MV,price,clrDimGray,0,STYLE_DASHDOT); // creates or moves the line
     }
   else if(showLevelOnDrag && ObjectFind(0,GetNameForLevel(9999999999999999,LEVEL_MV))>=0) ObjectDelete(0,GetNameForLevel(9999999999999999,LEVEL_MV));
  }
Reason: