Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MT4 Dotnet Core #18

Open
maartenschalekamp opened this issue Jan 22, 2023 · 11 comments
Open

MT4 Dotnet Core #18

maartenschalekamp opened this issue Jan 22, 2023 · 11 comments

Comments

@maartenschalekamp
Copy link

Good day,

I am trying to replicate what you have done for MT5 but to do it as well for MT4. When using the MtApiServiceNetCore I am able to connect, but somewhere I believe there is some issue with the data contract or something.

I get the following error:
System.ServiceModel.CommunicationException: 'Service connection failed! The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter https://tempuri.org/:GetQuotesResult. The InnerException message was 'There was an error deserializing the object of type System.Collections.Generic.List 1'[[MTApiService.MtQuote, MtApiServiceNetCore, Version=1.0.32.0, Culture=neutral, PublicKeyToken=null]]. The input source is not correctly formatted.'. Please see InnerException for more details.'

and the inner exception.
{"The input source is not correctly formatted."}

Any suggestions on what could be the issue. When using the MtApiService directly does work fine (in dotnet framework).

@lazou
Copy link
Owner

lazou commented Jan 22, 2023

Hi @maartenschalekamp, this also happens on my side, it is unrelated to mt4 or mt5. It has something to do with wcf versions >= 4.9.0. To better investigate this issue, I created the test server project for checking only the wcf communication. But recently I had no time for further analyzation, but it is on my Todo list. Sorry :(

To solve it on your end, you can just use the 4.8.0 wcf dependencies, with them I Do not face this issue and all is working as expected.

@lazou
Copy link
Owner

lazou commented Jan 22, 2023

Maybe some additional background. The json payload is for some methods generated directly in mql5, for others not. The GetQuoteResults is called directly after a connection is established.

@maartenschalekamp
Copy link
Author

Thank you for confirming. I really though I was doing something wrong. I will try downgrading to 4.8.0. Really appreciated!

Migrating the server part seems to be a big project as well, but there seems to be some limited support for WCF now in core from a community project.

@lazou
Copy link
Owner

lazou commented Jan 22, 2023

If you downgrade to 4.8.0, you have to re-add some workarounds. Just have a look at this commit for some details (e.g. the CallbackBehaviorAttribute). 91af112

Migrating the server part seems to be a big project as well, but there seems to be some limited support for WCF now in core from a community project.

Yep, but requires a better understanding of the mtapi implementation. I think that would be a nice goal to achieve in combination 😉

@lazou
Copy link
Owner

lazou commented Jan 29, 2023

@maartenschalekamp I did some debugging and found the issue for your observed exception. It is not related to the wcf dependencies (which still have another issue on versions greater than 4.8.0), but has something to do with the used .net core version. There is a regression in .net7, it will still work with .net6. Here are two issues I found for this behavior:

@maartenschalekamp
Copy link
Author

Thank you Lazou. I want able to work on my project for a while. I initially tried to just downgrade to 4.8.0 and then ran into other random issues. Downgraded to .net6 and it works now!

@cshawky
Copy link

cshawky commented Jul 23, 2023

Hi maartenschalekamp and lazou
This project looks really cool.
I have just come across MTAPI and hope to try it out this week on MT5. I much prefer C# programming than C++ and MQL, having spent a lot of effort creating my own EA on MQL4 many of its issues would be easily fixed through C#. I do not programme often enough for C++ to create a standalone app in C++. However, I am quite comfortable in C#.

I like the many changes lazou has done with his fork of vdemydiuk but the latter still has MT4.
I note also https://github.com/VeriEasi has a fork focusing on MT4, but has many commits behind lazou.

My use case combines both MT5 and MT4. Unfortunately, Maarten your MT4 development does not appear to be public, so I am not sure what direction to take.

What do you recommend?

Thanks

@lazou
Copy link
Owner

lazou commented Jul 23, 2023

Hi @cshawky, I decided to remove MT4 since I only use MT5 and could not test MT4 for my own. Additionally it made the project setup easier. That said, I personnally recommend the usege of MT5. But at the end it is up to you 😉

@cshawky
Copy link

cshawky commented Jul 23, 2023

@lazou that makes perfect sense. However, I am supporting an EA for multiple clients who use MT4 exclusively and their favorite broker does not support MT5. To solve limitations with that EA, the magic sauce needs to be done outside of MT4. I myself have started using MT5 and do like it. For that use case I only need a private copy service.
I might reach out to VeriEasi and see when he/she is at. At least that clone of your repository seems to have maintained the MT4 build. However, has not kept the MT5 updates from you synchronised. This may actually be reasonably easy to merge with a little cooperation, even if portions are declared "untested" or "limited testing".
Thanks

@cshawky
Copy link

cshawky commented Jul 30, 2023

Thanks, I've just started on this, with a fork. What is the current status for .net as I note a few different versions from .NET 5, 6 and framework 4.8 selected for different projects. Is it safe for .Net 7 yet or should one stick to an earlier version?

@lazou
Copy link
Owner

lazou commented Aug 8, 2023

I think it is totally fine to use NET7, but I have no experience with it until now (still using NET5). So at the end it is up to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants