MetaTrader
StockSharp integrates with MT4 and MT5 terminals through special connectors. To install these connectors, use Installer (for more details, see Installing and Removing Programs).
Both connectors are used in the same way, so below is the description of the process for connecting to MT5:
Setting Up the MT Connector
Select the MT connector in Installer and start the installation process.

Installer will ask which folder to install the connector in (it must be installed in the Experts folder).

If multiple terminals are installed, you need to choose the one where you want to install the connector.

After selecting the desired terminal, the path to the Experts folder will be displayed.

[!TIP]
- If the path cannot be automatically determined, you need to manually select it through directory search C:\Users\%your_user_name%\AppData\Roaming\MetaQuotes\Terminal\%many_letters_and_numbers%\MQL4\Experts\ (for MT5, the path will include MQL5).
Complete the installation and wait for it to finish. At the end of the installation, Installer will warn that you now need to configure the terminal. To do this, launch the MT terminal and connect to trading.
In the Tools->Options menu, select the Experts Advisors tab and make sure that permission for external DLL trading (Allow DLL imports) is enabled:

If the terminal was running during the connector installation (step 2), you need to refresh the list of experts by right-clicking on Experts and selecting Refresh from the menu:

Select the S# expert, right-click and choose Attach to a chart from the menu:

A settings window will appear where you can set the login-password (anonymous authorization is enabled by default), as well as the connection address (if connecting to multiple terminals at once, the addresses must contain unique ports).
A smiley icon should appear in the upper right corner of the chart (the first one encountered):

Also, information about the successful script launch, the number of instruments, should appear in the expert's log window.
If the MT4 or MT5 license is not obtained, a line similar to the following will appear in the log:

Open the connection settings in Terminal. Add the MetaTrader adapters for transactions and market data. Both use the FIX protocol. The screenshots show MT4 using
127.0.0.1:23000. The default port for MT5 is23001.

Similar settings need to be made in Designer, Hydra, or any API programs.
Login and password are left empty in case of anonymous authorization (previous item). If connecting to MT with multiple robots, a unique login must be provided for different connections identification.
[!TIP]
- The script must be launched before connecting StockSharp to MetaTrader and kept running as long as this connection is needed.
- To see historical candles in StockSharp, they need to be downloaded from the MetaTrader server. How to do this, read in MetaTrader's documentation.
After connecting, open the Instruments and Portfolios panels to see the instruments and accounts returned by the connection.
In case of errors, the connector logs are kept, which are available in the folder Experts\StockSharp\Data\Log:
