S#.MT4 and S#.MT5
Both connectors are used in the same way, so below I will describe the process of connecting to MT4:
MT connector setup
- All MT files should be installed to the folder C:\Users\%user_name%\AppData\Roaming\MetaQuotes\Terminal\%a lot of letters and numbers%\MQL4\Experts\ (in case of MT5 the path will contain MQL5). The structure eventually should look like this (root folder contains the MQL script and MT connector, StockSharp sub-folder contains necessary S#.API files:
- Start MT terminal and connect to trading.
- In menu Tools->Options select Experts Advisors tab and make sure you have enabled permission for external dll trading (Allow DLL imports):
- If during the installation of the connector (пункт 2) the terminal was running, then you need to update the list of experts by right-clicking on Experts and selecting in the Refresh menu item:
- Select S# expert in the tree, click the right button, and select in menu Attach to a chart:
- In the popup window you can specify login-password (leave it blank if you want anonymous access). Also, you can specify network address (in case of using multiple terminals you should specify unique port numbers).
On a chart (it should be the first random) at the right bottom corner you will see the smile icon:
And also in the expert logs window should appear information about the successful launch of the script.
- If MT4 or MT5 license is not valid, then the following line will appear in the log:
Connection to the MT is made via the FIX protocol, us uses FIX protocol connector. The app S#.Terminal is used as a demonstration. Below are the settings for transactional and market data connections (in case of MT5 by default port is 23001 instead of 23000):
Leave login and password are blank in case of anonymous access (prev step). In case of connection to MT by multiple applications, it is necessary to specify a unique login to identify different connections
- The script must be run before connecting StockSharp to the MetaTrader and do not stop it until this connection is needed.
- To see historical candles in StockSharp, they must be downloaded from the MetaTrader server. How to do it, read the documentation of MetaTrader itself.
In case of successful connection, the example should show a list of instruments and accounts:
- In case of errors, the logs of the connectors are placed into the folder Experts\StockSharp\Data\Log: