init and deinit
The functions init and deinit are special MQL functions that can be used in any Expert Advisor.
- The init function it called one time when the Expert Advisor is first attached to a chart.
- The deinit function is called one time when the the Expert Advisor is removed from a chart.
To use the init or deinit functions in VTS
- Create a new drawing name it init or deinit.
- Modify the drawing to perform the required functionality.
- Save the drawing.
- From the ToolBox, under the System Functions menu, find the init or deinit menu item and drag it onto the main system drawing.
- Do not connect init or deinit Elements! Simply existing on the main system drawing will cause each function to execute properly. If you connect the Elements, they will be called on each tick just like any other Element.
Note: For Expert Advisors that created Objects (such as vertical and horizontal lines), it can be convenient to create a deinit function that uses the MQL function ObjectsDeleteAll to removes all lines from the price chart when the EA is removed.