Please read Documentation on MQL5: Constants, Enumerations and Structures / Chart Constants / Types of Chart Events
CHARTEVENT_MOUSE_WHEEL
Pressing or scrolling the mouse wheel (if CHART_EVENT_MOUSE_WHEEL=True for the chart)
Mouse wheel event (if CHART_EVENT_MOUSE_WHEEL=true for the chart)
CHARTEVENT_MOUSE_WHEEL
Flags of states of keys and mouse buttons, the X and Y coordinates of the mouse pointer. See description in the example below
The Delta value of the mouse wheel scroll
—
For CHARTEVENT_MOUSE_MOVE event the sparam string parameter contains information about state of the keyboard and mouse buttons:
Bit
Description
1
State of the left mouse button
2
State of the right mouse button
3
State of the SHIFT button
4
State of the CTRL button
5
State of the middle mouse button
6
State of the first extra mouse button
7
State of the second extra mouse button
Please read Documentation on MQL5: Constants, Enumerations and Structures / Chart Constants / Types of Chart Events
CHARTEVENT_MOUSE_WHEEL
Pressing or scrolling the mouse wheel (if CHART_EVENT_MOUSE_WHEEL=True for the chart)
int OnInit() { ChartSetInteger(0,CHART_EVENT_MOUSE_WHEEL,1); ChartSetInteger(1,CHART_EVENT_MOUSE_MOVE,true);
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { if (id== CHARTEVENT_MOUSE_WHEEL) { printf("Mouse Middle button clicked"); }
it's doesn't work, can you help me please?
int OnInit( void ) { ChartSetInteger( 0, CHART_EVENT_MOUSE_WHEEL, true ); ChartSetInteger( 0, CHART_EVENT_MOUSE_MOVE, true ); return INIT_SUCCEEDED; }; void OnChartEvent( const int id, const long &lparam, const double &dparam, const string &sparam ) { if( id == CHARTEVENT_MOUSE_WHEEL ) Print( "Mouse wheel moved" ); if( id == CHARTEVENT_MOUSE_MOVE && sparam == "16" ) { Print( "Middle button clicked" ); }; };2023.06.01 20:47:55.192 test (EURUSD,H1) Mouse wheel moved 2023.06.01 20:47:55.252 test (EURUSD,H1) Mouse wheel moved 2023.06.01 20:47:58.722 test (EURUSD,H1) Middle button clicked 2023.06.01 20:47:59.772 test (EURUSD,H1) Middle button clicked
Also, remember that the middle mouse button enables the Crosshair on the chart.
Please note that I used "16" for a quick and dirty solution, but you should treat it as a bit field in case multiple states occur at the same time.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use