My application is based on asp.net mvc , c# and my client want to connect this application with MT4 server.There is server api https://support.metaquotes.net/ru/docs/mt4/api/server_api which is in c++.This api help to login at MT4.My application is in Asp.net mvc c# and i want to call these c++ methods in c#. Is it possible to work with c#. tAHNKS
Asked
Active
Viewed 1,156 times
0
-
Can you add more details to your question? What do you want to know that would not be satisfied by clicking through the first five or ten links of the obvious Google search on the topic? – nvoigt Oct 26 '16 at 05:08
-
Do you have manager/administrator access to server? – Uriil Oct 26 '16 at 05:32
-
No we don't have any access.But this site have php version of code also through which we can communicate to live server.providing ip address and other credential. – Mohsin Ali Oct 26 '16 at 06:31
1 Answers
0
Server API is tend to be used to write server plugins, which will be loaded into server memory at runtime. You can use .NET code there, however it's not the best idea.
There is Manager API, I think, it's functionality is sufficient for web application. However officially it has only C++ API. But you can use my wrapper to access it from ASP.NET: https://github.com/Uriil/MetaTrader4.Manager.Wrapper
But both options requires manager credentials

Uriil
- 11,948
- 11
- 47
- 68
-
Thanks Urill, So using your wrapper should i create new account on MT4 server.So my all concern is to connect with MT4 with manager credential and then add new user to MT4. – Mohsin Ali Oct 26 '16 at 07:21
-
-
Can you expose any method or Interface for User Registration which i invoke in c# and pass value to c++ method.Please any link or guide line. – Mohsin Ali Oct 26 '16 at 08:09
-
-
ClrWrapper took login as integer but i have string value provided by my client. Here is your example Login = 123456.What should i do now.Sorry – Mohsin Ali Oct 26 '16 at 09:49
-
Internally login is integer, and if you have string, it means your client have some custom authentication and you need to discuss it with him – Uriil Oct 26 '16 at 09:51
-
-
I get new credentials and added a user using UserRecordNew and it returned me 1.so my client told me it should be 4,5 digits like 1234.In my case it returned 1 so what it does means. – Mohsin Ali Oct 26 '16 at 10:27
-
Result is status of operation. Newly created login will be assigned to Login property of passed UserRecord object. Mandatory parameters: Name, Group, Password, InvestorPassword, Leverage – Uriil Oct 26 '16 at 11:04
-
3 2016.10.44 15:44:07.150 185.97.161.40:445 '1': new user record (Invalid parameters). Log file helped me.Thanks once again – Mohsin Ali Oct 26 '16 at 11:23
-
Check that you provided existing group name, and passwords at least 7 characters and contain lowercase, uppercase and number – Uriil Oct 26 '16 at 11:24
-
Dear Uriil i'm facing Failed to instantiate manager instance exception. – Mohsin Ali Oct 27 '16 at 10:15
-
-
I created my MVC4 project in vs2013 and installed it via Nuget Package Manager after that inside my home controller i instantiate using (var metatrader = new ClrWrapper(new ConnectionParameters { Login = 1, Password = "passwordValue", Server = "111.11.111.33:111" })) { IList
users = metatrader.UsersRequest(); } instantiate manager instance exception – Mohsin Ali Oct 27 '16 at 10:35 -
-
-
-
Additional information: Failed to instantiate manager instance. var path = Server.MapPath("~/bin")+@"\bin\P23.MetaTrader4.Manager.ClrWrapper.dll"; using (var metatrader = new ClrWrapper(new ConnectionParameters { Login = 1, Password = "password", Server = "111.11.111.11:111" },path )) { IList
users = metatrader.UsersRequest(); } – Mohsin Ali Oct 27 '16 at 11:13 -
An exception of type 'P23.MetaTrader4.Manager.Contracts.MetaTraderException' occurred in P23.MetaTrader4.Manager.ClrWrapper.dll but was not handled in user code Additional information: Failed to instantiate manager instance – Mohsin Ali Oct 27 '16 at 11:17
-
-
-
-
You don't need to broke your code again.Its perfectly working.I come with little typo mistake. – Mohsin Ali Oct 27 '16 at 11:49
-
When i execute it on my client machine it throws now Could not load file or assembly 'P23.MetaTrader4.Manager.ClrWrapper.DLL' or one of its dependencies. The specified module could not be found.Should i need it add it in web.config? – Mohsin Ali Oct 27 '16 at 12:11
-
-
Its not about hosting, actually i gave the running solution project to my client and he try to run on his side and he told me about Exceptoin Could not load file or assembly 'P23.MetaTrader4.Manager.ClrWrapper.DLL'. – Mohsin Ali Oct 28 '16 at 04:23
-
-
got it as it work perfect as i already have vs2015 , for hosting what should i consider on hosting server. do i need visual c++ redistributable 2015 x86 on hosting server. – Mohsin Ali Oct 28 '16 at 05:02
-
great, any guide or explicit steps about adding these package to my solution.Thanks – Mohsin Ali Oct 28 '16 at 05:11
-
-
i already have these on my machine but for hosting server do i need to copy these from Microsoft web site and add it to my solution.Its little bit confusing for me that's why i asked you.Any how thanks i'm googling now – Mohsin Ali Oct 28 '16 at 05:16
-
-
My client has Hostgator hosting.Is there a ways of installing binaries or packages directly on any hosting site. – Mohsin Ali Oct 28 '16 at 09:31
-
I guess it depends on provider and you have to talk with your server administrator. I always using dedicated server, so it's not an issue in my case – Uriil Oct 28 '16 at 09:40
-
Uriil i got reply You wont be able to us c++ on a shared windows plan.You will have to get a dedicated server to get that installed.So Is there any other way? – Mohsin Ali Oct 29 '16 at 08:02
-
You will have to investigate it on your own. However I would consider switching to dedicated server, since prices for them are low – Uriil Oct 29 '16 at 11:27
-
Uriil i want to get user history on MT4 by its MT4 id.Is there any method which return me a collection.i am looking for fields type,balance,equity. – Mohsin Ali Dec 10 '16 at 07:42
-
-
-
One more thing Uriil i need a method which updates the specific user information. – Mohsin Ali Dec 12 '16 at 09:25
-
Uriil UserRecordUpdate is not wroking. i am trying to update the balance field.When i checked the fetched data its Id field is empty but login and other fields values are still there.Record not updated.Is UserRecordUpdate method required Id values for updating. – Mohsin Ali Dec 17 '16 at 11:37
-
To change balance, u need to use TradeTransaction. But I suggest u to read documentation for mtmanapi on support.metaquotes.com – Uriil Dec 17 '16 at 11:41
-
TradeTransaction accepts TradeTransInfo instance and it has no field with balance.Actually i need a method which update the UserRecord class field Balance.UserRecordUpdate take UserRecord instance but it doesn't update the Balance field. – Mohsin Ali Dec 17 '16 at 16:35
-
-
-
https://support.metaquotes.net/en/docs/mt4/api/manager_api/manager_api_dev – Uriil Dec 17 '16 at 19:45
-
Uriil TradeTransInfo accepts two parameters info.type = TT_BR_BALANCE; info.cmd =OP_BALANCE; I need guide on TT_BR_BALANCE and OP_BALANCE values.I got this in docs.this example is in c++ – Mohsin Ali Dec 19 '16 at 17:04
-
Complete example //Deposit / Withdraw (assumes login: the account of the user, amount how much to deposit) TradeTransInfo info={0}; info.type =TT_BR_BALANCE; info.cmd =OP_BALANCE; info.orderby=login; info.price=amount; //negative for withdrawal strcpy_s(info.comment, "No comment"); int res=ExtManager->TradeTransaction(&info); if (res != RET_OK){ MessageBox("Could not deposit"); – Mohsin Ali Dec 19 '16 at 17:04
-
i tried with only price field.here is my code.var info = new TradeTransInfo(); info.OrderBy = 123456; //Login value //info.Cmd = OP_BALANCE; info.Price = -model.LiveUserWithdrawFund.Amount; var i= metatrader.TradeTransaction(info); – Mohsin Ali Dec 19 '16 at 17:07
-
I want to update Balance values as user want to withdraw his money.I also read the doc but i'm failed to understand. https://support.metaquotes.net/en/forum/3349 – Mohsin Ali Dec 19 '16 at 17:11
-
i got the values. var info = new TradeTransInfo(); info.OrderBy = 123456; info.Cmd = TradeCommand.Balance; info.Price =- model.LiveUserWithdrawFund.Amount; var i= metatrader.TradeTransaction(info); – Mohsin Ali Dec 19 '16 at 17:25
-
-
-