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

lib does not work in MetaTrader 600, after compilation inside of new MetaEditor #2

Closed
ungratefulson opened this issue Feb 25, 2014 · 10 comments
Assignees
Milestone

Comments

@ungratefulson
Copy link

First, thank you so much for this library, and for sharing it (very cool!). I have been using it for the past year or so, and it has stopped working in MetaTrader 600 (after compilation). Unfortunately, I'm not familiar with 'real' C/C++ coding, but found the new version of MT (can) no longer send strings (ie. ip sub/pub addresses, etc) to external DLL's, but rather char arrays; though I wouldn't know how/where to correct this. Was curious whether anyone else was experiencing this issue, and whether this might be the cause? Cheers!

Edit: to be clear, the library loads in MT (eg. can see what version of zmq is running), but the setters for pub/sub are failing (again possibly due to the changes from string to char[]?)

Found this on MQL(4) forum: "Since build 600 of MT4 was released, it's no longer easy to communicate with DLLs that use ANSI format for strings because strings in MQL4 are now in UNICODE format"

@AustenConrad AustenConrad self-assigned this Feb 26, 2014
@AustenConrad AustenConrad added this to the v2.0.0 milestone Feb 26, 2014
@AustenConrad
Copy link
Owner

Thank you for bringing this to my attention. I wasn't aware of this as I haven't updated my trading systems to MetaTrader build 600 yet. I will try to get this fixed as soon as time allows. Since it appears that MetaTrader made quite a few changes, I will tag the existing code base a v1.0.1 and release the updated version for build 600 as v2.0.0

@ungratefulson
Copy link
Author

Hi Austen, I was able to confirm that the necessary changes are inside of mql4zmq.mqh; all calls made/received to the dll (ie. mql4zmq_func) that refer to 'string' need to be 'uchar[]'. Also, s_recv needs to have a couple of things added to avoid memory leaks...I have made all these changes, but am afraid I'm a newb with the GitHub stuff so don't know how to pass these back to you for your perusal...suggestions?

@AustenConrad
Copy link
Owner

That's great! The typical way to collaborate is to:

  1. Fork my repository.
  2. Make the necessary changes.
  3. Commit the changes to your fork.
  4. Then on github.com, go to your fork of my repository and click on the green icon 'compare, review, create a pull request' button. From there you can generate a pull request.
  5. I'll review the code within the pull request and then merge it into the codebase for v2.

For more on collaborating on Github: https://help.github.com/articles/using-pull-requests

@ungratefulson
Copy link
Author

Good morning,

I just realized/remembered that I am not using your mql4zmq.mq4 file (or
the bridge, only mql4zmq.mqh); and that I didn't make any changes to func
ping (guessing that's in your .dll?). Also, there's a poorly implemented
'exception' handler on line 238, where if the message string returned to
s_recv has a length of 0, it returns an empty string without stating the
message had zero length. Finally, I've additionally read this fix (re:
using a pointer to grab the message via its address) will not work on 64
bit.

Noticed you reopened the issue, hope these are one of the causes for any
errors you might be experiencing.

Cheers,
Warren

On Thu, Feb 27, 2014 at 9:57 PM, Austen Conrad notifications@github.comwrote:

Reopened #2 #2.

Reply to this email directly or view it on GitHubhttps://github.com//issues/2
.

@AustenConrad
Copy link
Owner

Thanks for the additional info Warren,
I actually reopened the issue because I accidentally tapped close in the Githib issues app.

When reviewing your build 600+ patch I got thinking about how many type changes I had to make within the main DLL because of the type limitations of MetaTrader pre-600. I'm now going to see how many of those type changes I can get rid of with the hope of getting as close to the original ZeroMQ spec as possible.

For now I will merge in your patch as v2.0.0-pre and then ship v2.0.0 with any additional DLL changes I can make next week. If possible, are you willing to edit your pull request to go into the v2.0.0-pre branch I just created?

@ungratefulson
Copy link
Author

Sure, no worries. I'm going to have to read the documentation...for the
life of me can't figure out how/where to make those changes...not liking
the gui version of git very much ;)

On Fri, Feb 28, 2014 at 2:39 PM, Austen Conrad notifications@github.comwrote:

Thanks for the additional info Warren,
I actually reopened the issue because I accidentally tapped close in the
Githib issues app.

When reviewing your build 600+ patch I got thinking about how many type
changes I had to make within the main DLL because of the type limitations
of MetaTrader pre-600. I'm now going to see how many of those type changes
I can get rid of with the hope of getting as close to the original ZeroMQ
spec as possible.

For now I will merge in your patch as v2.0.0-pre and then ship v2.0.0 with
any additional DLL changes I can make next week. If possible, are you
willing to edit your pull request to go into the v2.0.0-pre branch I just
created?

Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-36392077
.

@AustenConrad
Copy link
Owner

Thanks for all the help! I have merged pull request #6 into the v2.0.0-pre branch.

@ungratefulson
Copy link
Author

The pleasure's mine Austen; thank you for sharing. Happy trading!

On Mon, Mar 3, 2014 at 3:35 PM, Austen Conrad notifications@github.comwrote:

Thanks for all the help! I have merged pull request #6https://github.com/AustenConrad/mql4zmq/pull/6into the v2.0.0-pre branch.

Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-36562711
.

@AimHigher
Copy link

First of all, thanks for making this available. I am new to ZMQ but already see the potential after having played around with some C# examples. I am completely new to GitHub so I have no idea if this is the correct way of addressing the issue I am having. I am currently using MT build 600+. After some minor edits of your examples, I can compile them fine. I also have no problem using PUB functionality and my C# tester app could subscribe without an issue e.g. to receive ticks. However, I can't get the SUB in MQL to work as it should. If I leave the .mqh file as is, MT4 crashes every time when running my SUB EA. If I edit the .mqh file to comment out the line LocalFree(recvPtr); in helper function "s_recv" then the SUB works i.e. receives messages but there is a memory leak instead. Since I leave MT running for long periods of time on a VPS with low RAM, it would quickly become an issue. Any ideas of how to fix/work around this?

Regards,
Tom

@ungratefulson
Copy link
Author

Hi AimHigher, taking a quick (uneducated) stab at this, I vaguely recall
this method will not work on 64 bit Windows (so you'll need to check what
your VPS is running), in which case you'd most likely need to modify to
accommodate whatever libs/dlls/methods it uses in place of LocalFree;
sorry, I'm not even remotely capable in this area...

On Thu, Mar 27, 2014 at 1:08 PM, AimHigher notifications@github.com wrote:

First of all, thanks for making this available. I am new to ZMQ but
already see the potential after having played around with some C# examples.
I am completely new to GitHub so I have no idea if this is the correct way
of addressing the issue I am having. I am currently using MT build 600+.
After some minor edits of your examples, I can compile them fine. I also
have no problem using PUB functionality and my C# tester app could
subscribe without an issue e.g. to receive ticks. However, I can't get the
SUB in MQL to work as it should. If I leave the .mqh file as is, MT4
crashes every time when running my SUB EA. If I edit the .mqh file to
comment out the line LocalFree(recvPtr); in helper function "s_recv" then
the SUB works i.e. receives messages but there is a memory leak instead.
Since I leave MT running for long periods of time on a VPS with low RAM, it
would quickly become an issue. Any ideas of how to fix/work around this?

Regards,
Tom

Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-38847321
.

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