- Что нового
MT5 To Interactivebrokers Trader
With MT5 to Interactive Brokers(IB) Trader, you can:
1. Load chart data from IB to MT5, and Analyze with all standard or customer Indicators.
2. Place Orders to IB Account Directly in MT5.
3. Make your Own EAs upon IB Securities by only making minus changes of the trading function.
Copy the "Mt5ToIBTraderEn.ex4" and sample files to [MT5 Data Folder]->MQL5->Experts.
2) MT5 Settings
Add the IP Address to the MT5 Allowed URLs in 'Tools->Options->Expert Advisor'.
3) TWS Configuration
Find “Global Configuration” in Menu of TWS. Tick “Enable ActiveX and Socket Clients”. Delete the tick of “Read-Only Api”.
4) Input Parameters
Drag “Mt5ToIBTraderEn” to MT5 Chart. Fill the input parameters.
|IP Address||IP Address of host in which TWS or IBGateway is opened. |
Fill “127.0.0.1” if the same computer is used.
|ClientID||Identifier of connection to TWS. Any positive integer. Please use different number for multiple connections.|
|Event Milliseconds||Periodical timer to process the program.|
|Default Account Code||Account code must be specified if the TWS account has multiple Account Code(e.g. U123456). The program will use the first one obtained if not filled in the field.|
|Bridge Mode|| |
1. Please fill different Client ID for different connections to the same IB Account Code.
2. Since the mt5 program can only be run in the mode of single thread, the big data flow of the bridge may be blocked and delayed. So we suggest users to create the one connection of Trading Mode and multiple Market Mode.It is suggested to select less than five symbols for each market-mode connection.
|Reconnect Wait Seconds(Should Differ from other Bridges)||Auto Re-connect waiting seconds. Should be filled with different number to avoid simultaneous requests, which may cause potential abnormal.|
5) Multiple Bridge Mode
When creating multiple bridge mode, different ClientID number should be filled in parameters.
Recommendation on multiple bridge mode:
i. Open One connection(one chart) with Trading Bridge Mode.
ii. One or more connections of Market Bridge Mode in different chart.
iii. Less than 5 symbols for one market bridge is suggested. Less than 3 symbols is best.
IB Symbol Management
After click “SymbolsSetup” in the chart control, then you can search IB Symbols and add to the watch list of MT5.
1) Order Type
Supported order types are as below:
- MKT, Market Order
- LMT, Limit Order
- STP, Stop Order
- MTL, Market to Limit
- STP LMT, Stop Limit
2) Basic trading function
- Buy / Sell
- CloseAll: Close all the position of the Selected Symbol
- Cancel: Cancel all the pending orders of the Selected Symbol
- CancelGlobal: Cancel all the pending orders of the account.
- Stoploss/Takeprofit: Place Stoploss or Takeprofit Order simultaneously when click Buy /Sell
- Drag Pending Order Line to Modify the Price
- Drag Position Line to Generate Stoploss or Takeproft Order
(Note: Please select(double click) the line before dragging.)
Making IB EAs
The attached file “Header_MT5ToIB.mqh” has listed all the IB functions as reference.
Trading and Account Functions of MT5 cannot send orders to IB account directly. We need to replace these function to IB functions.
Most of them can be simply add a prefix “IB_” to MT5 functions, such as IB_AccountInfoInteger.
The account structure of IB is similar to the “Netting” mode of MT5 account, so the usage of functions will be similar to Netting mode of MT5.
For IB EAs made by IB functions, users can run “Strategy Tester” commonly with any charts, including those fed by IB data.
Besides, during the usage of IB function, please be noted position_id(or position identifier)are always the Contract ID of the symbol.
Bug fixing for position cost calcuating for symbols with price magnifiered, such as YC, ZC.