Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #31 (permalink)  
Old 11-11-2008, 06:54 PM
Junior Member
 
Join Date: Dec 2005
Posts: 17
tworkman is on a distinguished road
Quote:
Originally Posted by bwilhite View Post
Since I was here, I thought I'd share my experience. What you are wanting to do can certainly be done, and I've done it many times myself.

When I first started writing DLLs for use in MT4 I couldn't ever get it to work in C++. I think the problem was/is that my project settings were always incorrect in Visual Studio (there's so d@$% many of them). Just recently I found an example from CodeGuru, which I was actually able to compile and use. Now I basically cleaned out that project and use it as a template.

In the meantime, I've been writing C# DLLs and using this excellent tool here. It basically takes the IL and alters it so that it can be called from unmanaged code. The only problem is that MT4 seems to exhibit a memory leak when doing this. I haven't definitively determined if that's due to MT4 or the altering of the IL, or what, but it happens.

Next I'll either be learning to write wrappers on C++ and/or just go ahead and learn C++. Hopefully that will address the memory issue.

Anyway, what you are wanting to do can definitely be accomplished. I've managed to write some pretty complicated DLLs for MT4 in C#, including things like remoting, raw sockets, http, WinForms. Pretty much anything you can do with .NET can be called from MT4 this way (you name it, and I've probably done it). And it's very reliable. The only problem is the relatively slow memory leak.
Were you ever able to identify the source of this slow leak bwilhite? I'd appreciate your help in this area if you are still willing. At the moment, I'm looking for a simple mql dll that will allow me to send and receive messages via sockets. I'm familiar with the basics of c#, so if I could find a way to take advantage of the, all the better.

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #32 (permalink)  
Old 11-11-2008, 08:29 PM
Junior Member
 
Join Date: Dec 2005
Posts: 17
tworkman is on a distinguished road
Quote:
Originally Posted by Magick View Post
bwilhite you are a life saver! That looks like a great tool. Do you, by chance, have a c# project that demonstrates communicating with MT from C#? What I am wanting to do is have my .net app tell MT when to trade. Or perhaps you can recommend a link that could help. Any help would be greatly appreciated.
Have you had any luck with this Magick? This is exactly what I am looking to do as well - have the .net app tell MT when and what to trade. Please let me know if you have found a solution.

I also appreciate and would like to hear more from bwihite. Do you have any sample c# dlls that you could share.

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #33 (permalink)  
Old 02-20-2009, 03:52 AM
Member
 
Join Date: Jul 2006
Location: Denver, Colorado
Posts: 51
AirforceMook is on a distinguished road
I've been working on my own DLL, and am running into the 127 error.

.cpp file contains (among other things):
Code:
MT4_EXPFUNC char* _stdcall DLLtest() {
	return("testing!");
}
header file contains:
Code:
#define MT4_EXPFUNC __declspec(dllexport)
MT4 file:
Code:
#import "mydll.dll"
string DLLtest();
Of course that's not ALL that they contain, but that's the pertinent information. Now, based on my understanding, I have everything there to try to call the function from MT4.

For some reason, it's just not "seeing" that it exists. I thought it was the fact my DLL lacked a .def file, but even after manually creating it one it still doesn't work. Also, I believe the MT4_EXPFUNC line means that the function will be exported anyhow, so a .def is unnecessary. The whole thing compiles fine, the EA runs fine right up until I try to call the function (as it can't see it) and then it stops.

I'm at my wits end. I really thought it was a .def issue, but the more I think about it, I don't believe it is.

BTW I'm using Visual C++ 2008 Express...

Thanks for any insight,
-Jason
__________________
//AirforceMook//
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #34 (permalink)  
Old 02-24-2009, 12:39 AM
Junior Member
 
Join Date: Oct 2005
Posts: 13
MG_1 is on a distinguished road
I've got the same 127 error using Visual C++ 2008 Express. No solution yet, if I find one, I will post it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #35 (permalink)  
Old 03-05-2009, 09:32 PM
Member
 
Join Date: Jul 2006
Location: Denver, Colorado
Posts: 51
AirforceMook is on a distinguished road
Major DLL Problems

I'm having some major problems getting my own DLL to function.

I finally got it to the point where it can call the dll from within an EA, and it doesn't give me the 127 error. Unfortunately, every single time I get an exception.

I've attached the entire project, and the MT4 files.

If one of you programming gods could just take a quick look at it, I'd be very grateful!

[NOTE: Compiled on Visual Studio C++ Express 2008 Edition, running on Vista x64 Ultimate dual-core w/ 6GB RAM]

-Jason
Attached Files
File Type: zip DLL_TEST.zip (1.39 MB, 110 views)
__________________
//AirforceMook//

Last edited by AirforceMook; 03-05-2009 at 09:44 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #36 (permalink)  
Old 03-05-2009, 09:33 PM
Member
 
Join Date: Jul 2006
Location: Denver, Colorado
Posts: 51
AirforceMook is on a distinguished road
Here's the EXCEPTION:

There has been a critical error
Time : 2009.03.05 14:32
Program : Client Terminal
Version : 4.00 (build: 220, 7 Nov 2008)
OS : Windows Vista Professional 6.0 Service Pack 1 (Build 6001)
Processors : 2 x X86 (level 15)
Memory : 4194303/4194303 kb
Exception : C0000005
Address : 8B222B17
Access Type : read
Access Addr : 8B222B17

Registers : EAX=00000000 CS=0023 EIP=8B222B17 EFLGS=00010246
: EBX=0045FE84 SS=002b ESP=061BFEF8 EBP=061BFF30
: ECX=00000000 DS=002b ESI=05703E68 FS=0053
: EDX=000000FF ES=002b EDI=05703E70 GS=002b

Stack Trace : 004552FD 76672DEB 7613E3F3 779BCFED
: 779BD1FF 00000000 00000000 00000000
: 00000000 00000000 00000000 00000000
: 00000000 00000000 00000000 00000000

Modules :
1 : 00400000 004F6000 c:\program files (x86)\fxdd - metatrader 4\terminal.exe
2 : 10000000 0001B000 c:\windows\system\expertsample.dll
3 : 16080000 00019000 c:\program files (x86)\bonjour\mdnsnsp.dll
4 : 71E70000 00123000 c:\windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8 b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msv cr90d.dll
5 : 746D0000 000BA000 c:\windows\system32\propsys.dll
6 : 74950000 00066000 c:\windows\system32\audioeng.dll
7 : 74AF0000 00014000 c:\windows\system32\msacm32.dll
8 : 74B10000 00021000 c:\windows\system32\audioses.dll
9 : 74B40000 00065000 c:\windows\system32\odbc32.dll
10 : 74BB0000 0011B000 c:\windows\system32\mfc42.dll
11 : 74DB0000 0002F000 c:\windows\system32\wdmaud.drv
12 : 74DF0000 0002D000 c:\windows\system32\wintrust.dll
13 : 74E70000 00005000 c:\windows\system32\msimg32.dll
14 : 74E80000 00038000 c:\windows\system32\odbcint.dll
15 : 74EC0000 00005000 c:\windows\system32\wshtcpip.dll
16 : 74F20000 00006000 c:\windows\system32\rasadhlp.dll
17 : 74F90000 00027000 c:\windows\system32\mmdevapi.dll
18 : 74FC0000 00080000 c:\windows\system32\uxtheme.dll
19 : 75040000 00007000 c:\windows\system32\midimap.dll
20 : 75080000 00009000 c:\windows\system32\msacm32.drv
21 : 75090000 00004000 c:\windows\system32\ksuser.dll
22 : 750B0000 00007000 c:\windows\system32\avrt.dll
23 : 750C0000 0002C000 c:\windows\system32\apphelp.dll
24 : 750F0000 0003B000 c:\windows\system32\mswsock.dll
25 : 75130000 0003B000 c:\windows\system32\rsaenh.dll
26 : 75170000 00012000 c:\windows\system32\pnrpnsp.dll
27 : 751A0000 00008000 c:\windows\system32\winrnr.dll
28 : 751B0000 0000F000 c:\windows\system32\napinsp.dll
29 : 751C0000 0000F000 c:\windows\system32\nlaapi.dll
30 : 751E0000 00021000 c:\windows\system32\dhcpcsvc6.dll
31 : 75210000 00007000 c:\windows\system32\winnsi.dll
32 : 75220000 0002C000 c:\windows\system32\dnsapi.dll
33 : 75250000 00035000 c:\windows\system32\dhcpcsvc.dll
34 : 75290000 00019000 c:\windows\system32\iphlpapi.dll
35 : 75440000 0019E000 c:\windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6001.18000_none_5cdb aa5a083979cc\comctl32.dll
36 : 75780000 0001E000 c:\windows\system32\userenv.dll
37 : 757A0000 00012000 c:\windows\system32\msasn1.dll
38 : 757C0000 000F1000 c:\windows\system32\crypt32.dll
39 : 758E0000 00039000 c:\windows\system32\oleacc.dll
40 : 75920000 00032000 c:\windows\system32\winmm.dll
41 : 75A90000 00060000 c:\windows\syswow64\secur32.dll
42 : 75B50000 0007D000 c:\windows\syswow64\usp10.dll
43 : 75BD0000 000D0000 c:\windows\syswow64\wininet.dll
44 : 75CA0000 000C8000 c:\windows\syswow64\msctf.dll
45 : 75E00000 00045000 c:\windows\syswow64\iertutil.dll
46 : 75E50000 0004A000 c:\windows\syswow64\wldap32.dll
47 : 75EA0000 00006000 c:\windows\syswow64\nsi.dll
48 : 75EB0000 00009000 c:\windows\syswow64\lpk.dll
49 : 75EC0000 00084000 c:\windows\syswow64\clbcatq.dll
50 : 75F50000 00090000 c:\windows\syswow64\gdi32.dll
51 : 75FE0000 000D0000 c:\windows\syswow64\user32.dll
52 : 760B0000 00110000 c:\windows\syswow64\kernel32.dll
53 : 761C0000 00029000 c:\windows\syswow64\imagehlp.dll
54 : 761F0000 00003000 c:\windows\syswow64\normaliz.dll
55 : 76200000 00144000 c:\windows\syswow64\ole32.dll
56 : 76350000 0018A000 c:\windows\syswow64\setupapi.dll
57 : 764E0000 0002D000 c:\windows\syswow64\ws2_32.dll
58 : 76510000 000C6000 c:\windows\syswow64\advapi32.dll
59 : 765E0000 00073000 c:\windows\syswow64\comdlg32.dll
60 : 76660000 000AA000 c:\windows\syswow64\msvcrt.dll
61 : 76710000 00060000 c:\windows\system32\imm32.dll
62 : 76770000 00129000 c:\windows\syswow64\urlmon.dll
63 : 768A0000 0008D000 c:\windows\syswow64\oleaut32.dll
64 : 76930000 000F0000 c:\windows\syswow64\rpcrt4.dll
65 : 76A20000 00B10000 c:\windows\syswow64\shell32.dll
66 : 77530000 00007000 c:\windows\syswow64\psapi.dll
67 : 77670000 00058000 c:\windows\syswow64\shlwapi.dll
68 : 77940000 00160000 c:\windows\syswow64\ntdll.dll

Call stack :
__________________
//AirforceMook//
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #37 (permalink)  
Old 03-29-2009, 02:45 PM
Junior Member
 
Join Date: Nov 2007
Posts: 21
PipTraderTim is on a distinguished road
creation .dll file with Dev-C++ Editor for Metatrader

Have somebody experience to create a .dll file with Dev-C++ that can be used for Metatarder.

When i trie it i think the .def file is not correct includet in the .dll file, and i become the error 127.

I have find a tutorial how I can create .dll file for Metatrader with Visual Studio, but not with the free version, in the free version there is no possibility to create MFC-Dll like in the tutorial I have see.

It would be helpfull for much people I think if anywhere is a tutorial how to create .dll files with the open source free editor Dev-C++ for use in Metatrader.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #38 (permalink)  
Old 03-30-2009, 07:11 PM
Mistigri's Avatar
Member
 
Join Date: Mar 2006
Posts: 34
Mistigri is on a distinguished road
dev-C++ name mangling ...

Hi Tim,

When using dev-c++ the def file is generated for you automatically the problem is that you end up with function names that look like this :

PHP Code:
EXPORTS
    _Z11GetSMAArrayP8RateInfoiiPd
@16 1
    _Z12GetHighValueP8RateInfoii 
_Z12GetHighValueP8RateInfoii@12 2
    _Z12GetHighValueP8RateInfoii
@12 3
    _Z13GetCloseValueP8RateInfoii 
_Z13GetCloseValueP8RateInfoii@12 4
    _Z13GetCloseValueP8RateInfoii
@12 5
    _Z11GetSMAArrayP8RateInfoiiPd 
_Z11GetSMAArrayP8RateInfoiiPd@16 
Now you need to make sure you add the following check around your code

PHP Code:
#ifdef __cplusplus
extern "C" {
#endif


#ifdef __cplusplus
}
#endif 
Attached are the sample files I did for VS2008 but this time using dev-c++ ...
Hope this helps
Attached Files
File Type: mq4 MistigriFX Sample Debug.mq4 (2.1 KB, 108 views)
File Type: zip MSFXDEV.zip (8.6 KB, 115 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #39 (permalink)  
Old 03-30-2009, 08:53 PM
Junior Member
 
Join Date: Nov 2007
Posts: 21
PipTraderTim is on a distinguished road
Hello Mistigri,

thank you much for your good help.

The online video i have found was also your video.

I have trie your new example for dev-c++ editor, it works, thank you for your help to get till here.

Regards
Tim
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #40 (permalink)  
Old 04-06-2009, 05:21 PM
Member
 
Join Date: May 2006
Posts: 43
veematics is on a distinguished road
Hello Patrick.
if i'm not wrong, you work with IBFX couple years ago... are you still with them now ? do you still collect ticks ?

Thanks for tutorial....it's the one i'm waiting for..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
c# metatrader, dll, dll forex, dll metatrader, dll mt4, ExpertSample.dll, file, FILE EXTENSION EX4, forex, internet, metatrader, metatrader c# DLL, metatrader dll, metatrader socket, metatrader sockets, MistigriFX, mql dll, mt4 dll


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
How do I use the files with .ex4 extension. NEEL123 General Discussion 6 12-19-2008 09:35 AM
About Fibo extension phildunn General Discussion 11 03-30-2008 01:31 PM
there is any script/program to create walk forward test data for metatrader???? giraia_br Metatrader 4 1 03-26-2007 01:44 AM
Please create an EA matrixebiz Expert Advisors - Metatrader 4 0 11-28-2006 08:19 PM


All times are GMT. The time now is 10:49 AM.



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