|
Really a C++ question...external DLL for MT4
Hi all,
I have an external DLL that I've written in C++. However, I'm still quite new to C++, so I think that might be why I'm having this problem. I have another version I've written in C# that works fine, except to make C# DLLs callable by MQL I have to alter them, and this alteration appears to cause small memory leaks. I'm hoping someone here can help me out with the C++ version. Here's the story:
I've been slowly developing various libraries for programming trading strategies. One of the things I'm trying to do is develop a consistent set of services for various things like logging, locking (thread-safe access to resources), and event notification. So basically, I'm trying to pull MQL up by its bootstraps into a more modern programming paradigm. Anyway, currently I'm working on a library that will allow EAs to receive notification of various trade events (placed, filled, closed). These events could be as a result of trades taken by the event-subscribing EA or from other EAs. To accomplish this, I'm using an external DLL that basically facilitates communication between EAs via message passing. There is a publishing EA that just looks for new trade events and when one occurs, it puts a message onto a queue for the subscribing EA (each subscriber has its own queue).
So the problem is this...As long as it's only one message being passed at a time, all works fine. Obviously that's not acceptable at all though. When more than one message is passed at a time, what I'm finding is that the first message gets corrupted (it keeps returning the message as "1" when instead it should be something like "FILLED,1005167"). The second message is fine, but the first is not. I haven't tested more than two messages yet, but presumably we'd still see the same thing.
I'd love it if someone knew the answer to what it is I'm doing wrong and could shed some light on my problem. A few notes: 1) I'm eventually going to be releasing this code under Apache 2.0 and so this source file is also being put out there under Apache 2.0...I intend to release this to the community when it's working fairly smoothly. 2) I've repeatedly said 'queue' here, but if you look at the source code you'll see me using a vector instead, and basically using it like a stack. Originally I had a queue, but changed it to a vector just on the off-chance that I was doing something wrong with the STL queue that I wasn't aware of. No such luck. The real implementation will be a queue, but for now neither queue nor vector are working correctly for me.
Thanks in advance for any insight.
Brandon Wilhite
Last edited by bwilhite; 05-23-2008 at 08:53 PM.
|