MT3 API for VB.net and C#
|
||||
|
Hey,
Just a quick note to trading robot developers and system automators. I successfully wrapped the mtapi.dll (MetaTrader version 3.x API) ages ago for my own use, and now I'm happy to share my hard work for free. My wrapped MetaTrader v3.xx API for dotNet framework features: - Object oriented way: much easier to program in .Net. - Safe multithreading: no more strange error codes returned. - Pumping Message Mechanism is programmed for you: all you need to do is to handle the messages. - A method to avoid 'Too frequent requests' error is programmed for you. - A very basic demo source code in VB.net is included. - Support Visual Basic .Net, C#, C++ .Net, and more dotNet compatible languages. You can download from www.fxfisherman.com/downloads/MT3API_dotNet.zip and feel free to give comment. Important: I really do suggest you understand how the original api works first; to do so you need to read the C source code provided with the original api. Requirement: Microsoft .Net Framework version 1.1 or newer. Disclaimer: The product is provided free of charge, and, therefore, on an "as is" basis, without warranty of any kind, express or implied, including without limitation the warranties that it is free of defects, virus free, able to operate on an uninterrupted basis, merchantable, fit for a particular purpose or non-infringing. In any case, the author will not be responsible or liable for ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, INDIRECT OR ANY OTHER LOSSES caused by using of this software library. Last edited by scorpion : 05-18-2005 at 12:37 PM. |
| The following users have thanked scorpion for useful post above: | ||
![]() |
|
|||
|
Quote:
I've gone through your example and everything works fine until I try managing orders. Looking at the original API and comparing to the methods in your wrapped dll, I am unsure of certain parameters that are required to send orders. For CloseOrder() I'm sure I'm using the correct price (just grabbing the closeprice from the traderecord) but I'm getting a NotEnoughRightsException, same with ModifyOrder(). Also, for SendOrderInfo, I'm unsure as to what the CRC and Req_Code shoudl be. Lastly, do I have to specify a price (current bid/ask) or can I leave that as 0? Again, many thanks |
|
||||
|
You'll need to use 2 connections logged into the same account concurrently. The first connection is used to listen for pumping messages, and the second connection is used for calling other methods. The NotEnoughRightsException occured because you used the same connection to call restricted methods while in pumping mode.
CRC and Req_code are not used in SendOrderInfo, and also you have to specify Bid price for sell order and Ask price for buy order. Simple, isn't it? |
|
|||
|
works a treat! One question though. I'm having a problem with spawning off multiple threads to kick off trades or even modify orders. The first command usually goes through pretty quickyl but the subsequent ones take qutie a few seconds and often result in too frequent requests exceptions.
I'm probably not explainign this very well. I have written a function that will modify a position by putting the stop to entry. Say I have 5 open positions all onside with no stops. Inside a loop a spwan off 5 threads that place a stop at entry for each one. Why this all doesn't happen in under a second I don't know. However, if I have 5 seperate instances of my application, and modify the stops for each position in a seperate instance of the app, it works fine. Confusing .... ![]() |
|
||||
|
It's good that you have it made some trades so soon.
Your problem: It takes long time to modify the 5 trades, because you use the one same connection. It is a mechanism designed by me to avoid 'Too frequent requests' errors raised by the low-level api. MetaQuotes imposed a rule inside their api to limit 1 trade transaction per 5 to 10 seconds. The only solution now is to spawn two or three more connections the same way you did in multiple instances. But you should aware that MetaQuotes also imposed a rule to limit the number of connections logged into the same account. I hope API version 4 doesn't have these limiations. ![]() |
|
|||
|
Quote:
|
|
|||
|
Quote:
|
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Socket problems with MT3 API | fxtrader625 | MetaTrader and ZeroCode | 2 | 12-29-2005 12:26 PM |
All times are GMT. The time now is 12:02 AM.
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Registered members have access to special online forex currency trading tools, software, mt4 expert advisors and indicators. Register now












MetaQuotes says the API4 will be realeased when MetaTrader 4 is in stable version.
Linear Mode

