Download MetaTrader 5

CHART_AUTOSCROLL according the mouse wheel

To add comments, please log in or register
Thierry Ramaniraka
422
Thierry Ramaniraka  

Hello all, I am trying to put the "CHART_AUTOSCROL" parameter false...when i use the wheel of the mouse. I succed with a simple click

            if (id==CHARTEVENT_CLICK)
            // if (id==CHART_MOUSE_SCROLL)
                  {
                        bool My_Button_Auto_Scroll_State=ObjectGetInteger(0,"My_Button_Auto_Scroll",OBJPROP_STATE);

                        if(My_Button_Auto_Scroll_State==true)
                              {
                                    ObjectSetInteger(0,"My_Button_Auto_Scroll",OBJPROP_STATE,false); // Set the CHART_AUTOSCROLL off
                              }
                        else
                              {
                                    ObjectSetInteger(0,"My_Button_Auto_Scroll",OBJPROP_STATE,true); // Set the CHART_AUTOSCROLL on
                              }
                  
                  }

But I did'nt succeed with the mouse's wheel. Can someone help me please.
Kind regards.

Thierry Ramaniraka
422
Thierry Ramaniraka  

I find another solution so it's ok now.

But i desire to know if there is a center/middle mouse click in mql ?
I can't find it.


Please help.
Regards.

Lorentzos Roussos
20439
Lorentzos Roussos  
Thierry Ramaniraka:

I find another solution so it's ok now.

But i desire to know if there is a center/middle mouse click in mql ?
I can't find it.


Please help.
Regards.

on event MOUSEMOVE , what does the "sparam" return when you click or roll the wheel ? 

kypa
933
kypa  

id==CHARTEVENT_MOUSE_WHEEL

and print all the params
Thierry Ramaniraka
422
Thierry Ramaniraka  
kypa:

id==CHARTEVENT_MOUSE_WHEEL

and print all the params
Lorentzos Roussos:

on event MOUSEMOVE , what does the "sparam" return when you click or roll the wheel ? 

Thank you,
I will follow that way.

Regards.

Thierry Ramaniraka
422
Thierry Ramaniraka  
kypa:

id==CHARTEVENT_MOUSE_WHEEL

and print all the params

It doesn't compile...
Is it working for mt4 ?


Edit : 
I tried "CHARTEVENT_CLICK" and "CHARTEVENT_MOUSE_MOVE" ... these 2 last work well.
Any idea please ?
kypa
933
kypa  

What are you trying to compile exacty?

int OnInit()
  {
   ChartSetInteger(0,CHART_EVENT_MOUSE_WHEEL,true);

   return(INIT_SUCCEEDED);
  }
 
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id==CHARTEVENT_MOUSE_WHEEL)
   Print("Lparam: "+(string)lparam+", Dparam: "+(string)dparam+", Sparam: "+(string)sparam);
  }

Does this work? If it doesn't - what build of MT4 you have?

It's not in MQL4 documentation, which is strange.

https://www.mql5.com/en/docs/constants/chartconstants/enum_chartevents

https://docs.mql4.com/constants/chartconstants/enum_chartevents

Types of Chart Events - Chart Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
Types of Chart Events - Chart Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
There are 9 types of events that can be processed using the predefined function OnChartEvent(). For custom events 65535 identifiers are provided in the range of CHARTEVENT_CUSTOM to CHARTEVENT_CUSTOM_LAST inclusive. To generate a custom event, the EventChartCustom() function should be used. For each type of event, the input parameters of the...
Thierry Ramaniraka
422
Thierry Ramaniraka  
kypa:

What are you trying to compile exacty?

Does this work? If it doesn't - what build of MT4 you have?

It's not in MQL4 documentation, which is strange.

https://www.mql5.com/en/docs/constants/chartconstants/enum_chartevents

https://docs.mql4.com/constants/chartconstants/enum_chartevents

Hi,
It gives me this error


I have this version of MT4

kypa
933
kypa  

Open a demo at MetaQuotes server, that will update your MT4 to latest beta. Which is 1121 and has the CHART_EVENT_MOUSE_WHEEL defined.

If you want to revert back to 'release' for some reason (if you encounter problems with the beta) delete whatever is in WebInstall folder (next to Terminal, which is where the MetaTrader data folders are) and reinstall from your broker's setup.

Thierry Ramaniraka
422
Thierry Ramaniraka  
kypa:

What are you trying to compile exacty?

Does this work? If it doesn't - what build of MT4 you have?

It's not in MQL4 documentation, which is strange.

https://www.mql5.com/en/docs/constants/chartconstants/enum_chartevents

https://docs.mql4.com/constants/chartconstants/enum_chartevents

I have see this code on the documentation :

//+------------------------------------------------------------------+
//| MouseState                                                       |
//+------------------------------------------------------------------+
string MouseState(uint state)
  {
   string res;
   res+="\nML: "   +(((state& 1)== 1)?"DN":"UP");   // mouse left
   res+="\nMR: "   +(((state& 2)== 2)?"DN":"UP");   // mouse right 
   res+="\nMM: "   +(((state&16)==16)?"DN":"UP");   // mouse middle
   res+="\nMX: "   +(((state&32)==32)?"DN":"UP");   // mouse first X key
   res+="\nMY: "   +(((state&64)==64)?"DN":"UP");   // mouse second X key
   res+="\nSHIFT: "+(((state& 4)== 4)?"DN":"UP");   // shift key
   res+="\nCTRL: " +(((state& 8)== 8)?"DN":"UP");   // control key
   return(res);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
  {
   if(id==CHARTEVENT_MOUSE_MOVE)
      Comment("POINT: ",(int)lparam,",",(int)dparam,"\n",MouseState((uint)sparam));
  }


It detects the MOUSE MIDDLE CLICK state.
I think there is a way to use it and turn it according my needs.

Kind of 

// if state&16 == DN
// then do something...

How can I translate this idea in "true" code please ?

Regards.

kypa
933
kypa  

It would do the same job as your previous code, the state variable is just the sparam of the event. And, of course, it still needs mouse move detecting allowed in initialization.

You should use id==CHART_EVENT_MOUSE_MOVE && sparam==<sparam of middle click> if you want your function on middle click.

The wheel click is assigned for haircross so you may run into conflict (sometimes your functions execute, sometimes a crosshair appears).

If you want to use the scroll wheel it's the same procedure with id==CHART_EVENT_MOUSE_WHEEL and lparam. Except you need Build 1121, because Build 1090 doesn't support it.

12
To add comments, please log in or register