Forex
Google
New signals service!

Go Back   Forex Trading > Downloads > Tools and utilities


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-02-2007, 08:25 PM
Member
 
Join Date: Aug 2006
Posts: 97
bwilhite is on a distinguished road
dll tutorial for Visual Studio 2005

Hi all,

I sent Codersguru a pm with a similar request, but figured it would be something that would be useful for the whole community. Also, he seems like a busy guy, so I'm hoping that maybe someone else out there might also have the answer:

Here is the problem...I am trying to write a .dll in C++ using VS 2005 to connect to MT4. I have read through Codersguru's tutorial, but I have had no luck compiling and implementing his .dll, which is strange because I've been able to compile my own .dll's (I'm sure this is something small as far as the compile goes...his pre-compiled dll-utilizing projects work for me just fine). I have also been able to compile the sample .dll provided by metaquotes, but I've had zero luck in using it. The problem, I believe, is the fact that I have been using VS 2005 and that the tutorial and sample dll are a bit dated. What I really would like to have is a very clear, step-by-step, set of instructions and sample code to compile a .dll in VS 2005 and then call it from MT4. Think in terms of explaining it to someone with almost no experience with VS 2005 C++ (the compiler and I don't get along very well.) Also, I would like to be able to use the .NET library, so this probably provides another wrinkle. My impression is that MT4 is not compatible with managed code. I have looked far and wide on the internet to find a solution to this, and have found many many resources....which all seem to be 3-6 years out of date...resulting in the same problem..."How the %&**&% do I do that in Visual Studio 2005!"

I have been working on my larger problem for about 5 weeks now, and I'm starting to get tired. I've got most of the issues worked out, but this last part, "connecting" MT4 to .NET has been the thorn in my foot for quite some time. Any help would be greatly appreciated.

Also, I intend to release some of my implementations to the public domain...for example, a "one-click" trading interface for day-traders (incorporating brackets, trailing stops, OCO, and other goodies). I intend to do most of my programming in the much friendlier language of C#, but this part needs to be addressed in C++ it seems.

Again, any help would be appreciated...a sample with instructions on how to compile in VS 2005 would probably do the trick. Thank you.

BW
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-04-2007, 03:38 PM
Member
 
Join Date: Dec 2006
Posts: 86
dwmcqueen is on a distinguished road
From what I understand, and my MetaTrader dlls have only been developed in either MingW or Visual C++ 7.1, the interface into the dll should not be managed. Couldn't you have a dll that is not managed access managed code in a second dll?

Not sure how technical you are, but the following explains how to call managed from native (which is what you will need to do):

http://blogs.msdn.com/deeptanshuv/ar...26/432870.aspx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-04-2007, 03:54 PM
Member
 
Join Date: Aug 2006
Posts: 97
bwilhite is on a distinguished road
dwmcqueen,

Thank you very much for the reply. I'm technical enough. Frankly, the link that you provided is probably one of the most straightforward and simple explanations of interop on the internet. I'm going to have to try this out, as this looks almost exactly like what I'm looking for (I'll know for sure after I dig into it more).

Another possible solution to the problem is using sockets to accomplish the interop.

Another question: Have you had success using your .dll's in MT4? Maybe I just need to switch compilers, but I haven't had success with VS 2005 compiled dll's (not in connecting to MT4). I probably will also try Bloodshed, which I guess uses mingW. I'll say this, though, the VS 2005 Express Edition compiler is a pain in the you know where, at least for C++...almost nothing seems to work.

Thanks for your help...if I have another question, could I pm you?

BW
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-04-2007, 05:19 PM
Member
 
Join Date: Nov 2005
Posts: 54
4xCoder is on a distinguished road
I've built dlls with Visual Studio 2005 that work with MT4 so I know it can be done.

I do remember running into problems like this, but don't remember the solutions. Some things to check are:

Check the .def file and make sure it exports correctly, and that it's included in the 2005 Solution.
Make sure all the exported functions are declared with __declspec(dllexport) and ___stdcall.

If that doesn't help PM me and I'll take a look at your projects.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-05-2007, 02:37 AM
Member
 
Join Date: Dec 2006
Posts: 86
dwmcqueen is on a distinguished road
CodeBlocks

Using CodeBlocks (www.codeblocks.org) and MinGW, I was able to compile dlls that worked fine in MT4. I am now testing out the VC++ 7.1 compiler to see if it works as well.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-05-2007, 02:39 AM
Member
 
Join Date: Dec 2006
Posts: 86
dwmcqueen is on a distinguished road
Quote:
Originally Posted by bwilhite
dwmcqueen,
Thanks for your help...if I have another question, could I pm you?

BW

Of course!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-09-2007, 04:24 PM
Member
 
Join Date: Dec 2006
Posts: 86
dwmcqueen is on a distinguished road
Did the above tutorial help? I'd be interested in knowing whether it was easy to make the connection to a C# app via the above method...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-09-2007, 04:31 PM
Member
 
Join Date: Aug 2006
Posts: 97
bwilhite is on a distinguished road
I couldn't get it to work...so I guess the answer is 'no.'

But I think the main problem was the Visual Studio C++ compiler. Frankly, I think it's a piece of junk. I've set it up according to the instructions at MSDN and double-checked and I'm always having problems with it. Others have similar problems to the ones I have.

I don't have these problems with the C# or VB compilers.

Also, just fyi, I've done a similar process before calling a C# compiled COM object from VB and I didn't have a problem. Of course, that doesn't really help here, because of MQL.

BW
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-09-2007, 10:45 PM
Member
 
Join Date: Dec 2006
Posts: 86
dwmcqueen is on a distinguished road
I'll take a look.

Did you specify a manual def file (as seen here - http://www.metatrader.info/node/150)?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 01-10-2007, 09:16 AM
Member
 
Join Date: Aug 2006
Posts: 97
bwilhite is on a distinguished road
I tried adding the .def file to the .dll and that didn't work. I've only tried this in Visual Studio so far. I haven't tried it with mingw yet. I'd really like to be able to cross the managed code to unamanaged code boundary, though.

BW
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy Language Tutorial! codersguru Metatrader 4 mql 4 - Development course 20 09-05-2008 05:43 AM
CATFX50 tutorial , help us dellan CatFx50 20 06-12-2007 11:38 AM
mql4 tutorial - Where is Lesson 1, etc.? ftsdPadawan Metatrader 4 mql 4 - Development course 2 01-15-2007 09:36 PM
Forex Data 2001 --> 2005 - TF =1 min, 15 min, Daily....Various Pairs..... De Vinci Tools and utilities 1 05-01-2006 10:31 AM


All times are GMT. The time now is 02:15 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.