- Types of Chart Events
- Chart Timeframes
- Chart Properties
- Positioning Constants
- Chart Representation
- Examples of Working with the Chart
Types of Chart Events
There are 11 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.
ENUM_CHART_EVENT
ID |
Description |
---|---|
CHARTEVENT_KEYDOWN |
Keystrokes |
CHARTEVENT_MOUSE_MOVE |
Mouse move, mouse clicks (if CHART_EVENT_MOUSE_MOVE=true is set for the chart) |
CHARTEVENT_MOUSE_WHEEL |
Pressing or scrolling the mouse wheel (if CHART_EVENT_MOUSE_WHEEL=True for the chart) |
CHARTEVENT_OBJECT_CREATE |
Graphical object created (if CHART_EVENT_OBJECT_CREATE=true is set for the chart) |
CHARTEVENT_OBJECT_CHANGE |
Graphical object property changed via the properties dialog |
CHARTEVENT_OBJECT_DELETE |
Graphical object deleted (if CHART_EVENT_OBJECT_DELETE=true is set for the chart) |
CHARTEVENT_CLICK |
Clicking on a chart |
CHARTEVENT_OBJECT_CLICK |
Clicking on a graphical object |
CHARTEVENT_OBJECT_DRAG |
Drag and drop of a graphical object |
CHARTEVENT_OBJECT_ENDEDIT |
End of text editing in the graphical object Edit |
CHARTEVENT_CHART_CHANGE |
Change of the chart size or modification of chart properties through the Properties dialog |
CHARTEVENT_CUSTOM |
Initial number of an event from a range of custom events |
CHARTEVENT_CUSTOM_LAST |
The final number of an event from a range of custom events |
For each type of event, the input parameters of the OnChartEvent() function have definite values that are required for the processing of this event. The events and values passed through this parameters are listed in the below table.
Event |
Value of the id parameter |
Value of the lparam parameter |
Value of the dparam parameter |
Value of the sparam parameter |
---|---|---|---|---|
Event of a keystroke |
CHARTEVENT_KEYDOWN |
code of a pressed key |
Repeat count (the number of times the keystroke is repeated as a result of the user holding down the key) |
The string value of a bit mask describing the status of keyboard buttons |
Mouse events (if CHART_EVENT_MOUSE_MOVE=true is set for the chart) |
CHARTEVENT_MOUSE_MOVE |
the X coordinate |
the Y coordinate |
The string value of a bit mask describing the status of mouse buttons |
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 |
— |
event of graphical object creation (if CHART_EVENT_OBJECT_CREATE=true is set for the chart) |
CHARTEVENT_OBJECT_CREATE |
— |
— |
Name of the created graphical object |
Event of change of an object property via the properties dialog |
CHARTEVENT_OBJECT_CHANGE |
— |
— |
Name of the modified graphical object |
Event of graphical object deletion (if CHART_EVENT_OBJECT_DELETE=true is set for the chart) |
CHARTEVENT_OBJECT_DELETE |
— |
— |
Name of the deleted graphical object |
Event of a mouse click on the chart |
CHARTEVENT_CLICK |
the X coordinate |
the Y coordinate |
— |
Event of a mouse click in a graphical object belonging to the chart |
CHARTEVENT_OBJECT_CLICK |
the X coordinate |
the Y coordinate |
Name of the graphical object, on which the event occurred |
Event of a graphical object dragging using the mouse |
CHARTEVENT_OBJECT_DRAG |
— |
— |
Name of the moved graphical object |
Event of the finished text editing in the entry box of the LabelEdit graphical object |
CHARTEVENT_OBJECT_ENDEDIT |
— |
— |
Name of the LabelEdit graphical object, in which text editing has completed |
Event of change of the chart size or modification of chart properties through the Properties dialog |
CHARTEVENT_CHART_CHANGE |
— |
— |
— |
ID of the user event under the N number |
CHARTEVENT_CUSTOM+N |
Value set by the EventChartCustom() function |
Value set by the EventChartCustom() function |
Value set by the EventChartCustom() function |
Example:
#define KEY_NUMPAD_5 12
|
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 |
Example:
//+------------------------------------------------------------------+
|
For the CHARTEVENT_MOUSE_WHEEL event, parameters lparam and dparam contain information about the states of the Ctrl and Shift keys, of mouse buttons, cursor coordinates and the mouse wheel scroll value. For a better understanding, run this Expert Advisor on a chart and scroll the mouse wheel, while pressing different buttons and holding down the keys described in the code.
Example of CHARTEVENT_MOUSE_WHEEL event processing:
//+------------------------------------------------------------------+
|
See also