<<

5/4/2014 Creating Metatrader DLLs with Lazarus / @ Forex Factory

Login 6:21am Google Powered

Home Forums Trades Calendar News Market Brokers

Platform Tech / 7 Subscribe Reply to Thread Options Creating Metatrader DLLs with Lazarus / Free Pascal Search This Thread Page 1 2 3 4 5 First Unread Last Post Go to Post#

Go to Page# First Post: Feb 6, 2010 5:54pm | Edited Dec 15, 2010 3:06am Quote Post 1 Bookmark Thread 7bit Printable Version

In this thread i will try to collect all the small bits of information that are not so obvious but needed to create DLLs that play together with Metatader, a collection of minimal and self contained code snippets that illustrate how things are done. The intended audience are people already familiar with programming, this is no Pascal tutorial, i will focus only on all the little things that need to be known for Metatrader specific development projects.

I will use Lazarus, the free IDE containing the the Free Pascal FPC, an excellent and very advanced (Object- )Pascal Compiler. I chose Lazarus/FPC because it is by far the easiest and most efficient tool for this job that is available today, and it is free!

Make sure you are downloading the 32 bit version, even if you are running Windows 64 bit on x64 hardware, Metatrader is a 32 bit application and can only use 32 bit DLLs, the 64 bit version of Lazarus/FPC would by default produce 64 bit binaries which can not be used for our purpose.

To create a new DLL project (if you started Lazarus for the first time) click on Project -> new project -> . Give it a meaningful name and save it into an empty folder. The project will initially consist of only two files. An .lpi file containing all compiler settings and and .lpr file containing the source code, these two files are all you need to backup, pass on to your colleagues or manage in a source code repository. Additional units (if you decide to split up bigger projects) are saved as individual .pas files.

If you come from a background you will find it notable that there is no need for make, .def or whatever-files, everything that compiler and linker need to know is written in the pascal source itself, you simply throw the main unit at the compiler and it will figure out everything by itself: http://www.at.freepascal.org/advantage.html

I will expand this first Posting over time with examples of increasing complexity, whenever I have new examples.

1. Minimal example with strings

I will start this thread with a minimal example of a working dll that will show you how to pass strings to your DLL and how to return strings to Metatrader. Since we are using modern Object-Pascal instead of ancient and clumsy C or C++ it is really easy and intuitive:

This is all that is needed on the Pascal side:

Inserted Code

[b]library[/b] minimal;

[color=DeepSkyBlue]{$mode objfpc}{$H+}[/color] FXCM Specs [b]uses[/b] sysutils; Similar Threads

Free trial- MYFX - [color=SeaGreen]// strings from and to Metatrader will always be passed METATRADER plug in - // as PChar which is a pointer to a nullterminated C-string.[/color] revolutionising trade [b]function[/b] foo(x: double; y: [color=Blue]PChar[/color]): [color=Blue]PChar[/color]; [b management - ][color=Red]stdcall[/color][/b]; metatrader [b]var[/b] 32 replies s :[color=Black]ansistring[/color]; [color=SeaGreen]// reference counted and memory manag Free EA Creating ed strings.[/color] Software 2 replies [b]begin[/b] IPC with Lazarus and [color=SeaGreen] // our PChar will be copied into an ansistring automatically, MT4 // no need to worry about the ugly details of memory allocation.[/color] 0 replies s := 'Hello ' + FloatToStr(x) + ' ' + y + '!'; A Free Indicator for Metatrader Mt4 [color=SeaGreen] // cast it back into a pointer. Metatrader will copy the 10 replies // string from the pointer into it's own memory.[/color] result := [color=Blue]PChar[/color](s); [b]end;[/b]

[b]exports[/b] foo; [b] begin end.[/b]

and this is the corresponding mql4:

Inserted Code http://www.forexfactory.com/showthread.php?t=219576 1/9 5/4/2014 Creating Metatrader DLLs with Lazarus / Free Pascal @ Forex Factory

#import "minimal.dll" [color=SeaGreen]// declare the imported function exactly as it is exported by the dll[/c olor] [color=Blue]string[/color] foo(double x, [color=Blue]string[/color] y); #import

int init(){ [color=Blue]string[/color] s = foo(42.3, "Worlds"); Print(s); [color=SeaGreen]// will print "Hello 42.3 Worlds!"[/color] }

int start(){ }

The very first and most important thing you need to know about DLLs used for MT4 is marked with red color: Metatrader assumes the 'stdcall' calling convention which means MT4 will push the arguments onto the stack from right to left and our function is responsible for cleaning the stack before returning. FPC's default calling convention would be 'register', also known as 'Borland fastcall', which would use processor registers for the first three 32 Bit arguments. Using the wrong calling convention would immediately crash Metatrader with a segfault due to a messed up stack. Thus we must decorate all exported functions with the keyword stdcall. Another option for achieving the same goal would be the compiler directive {$CALLING STDCALL} at the top of each unit containing exported functions.

2. Passing doubles and integers by reference

By reference means in Metatrader simply putting an ampersand & behind the type identifier in the function declaration and the function can then write values to these arguments. This is a convenient way to return more than one value from a Home funcFtoiornu.m Usnfortunately wiTthra imdepsorted functionsC athleisn sdeaer ms only possibNlee wsith arrays. For soMmaer wkeetird reason we caBnronkoetrs just pass scalar values by reference to a DLL, MT4 would just push a bunch of zeros onto the stack which is quite useless.

We need to do this with the help of arrays. If we pass an array by reference MT4 will pass a Pointer to the first array element which is easily handled in Pascal either by a typed pointer to an array that can be dereferenced or even more elegantly by declaring the arguments with the keyword var which is technically the same, only nicer:

Inserted Code

[b]library[/b] testlib;

[color=DeepSkyBlue]{$mode objfpc}{$H+}[/color]

[b]type[/b] TDPair = array[0..1] of double; TIPair = array[0..1] of LongInt;[color=SeaGreen] // 32 bit int[/color]

[color=SeaGreen]// function parameters declared as var will accept pointers.[/color] [b]procedure[/b] VarsByReference([color=Red][b]var[/b][/color] a: TDPair; [color=Red][b]var [/b][/color] b: TIPair); stdcall; [b]begin[/b] [color=SeaGreen]// now let's make some changes to the variables[/color] a[0] += a[1]; a[1] -= a[0]; b[0] += b[1]; b[1] -= b[0]; [b]end;[/b]

[b]exports[/b] VarsByReference;

[b]begin[/b] [b]end.[/b]

and in mql4:

Inserted Code

Platform Tech / Creating Metatrader DLLs with Lazarus / Free Pascal Page 1 2 3 4 5

http://www.forexfactory.com/showthread.php?t=219576 2/9 5/4/2014 Creating Metatrader DLLs with Lazarus / Free Pascal @ Forex Factory

#import "testlib.dll" [color=SeaGreen] /** * the function takes 2 arrays which will be * passed by reference. On the DLL side this * means we will receive Pointers to the * the memory locations of the arrays */[/color] void VarsByReference(double[b][color=Red]&[/color][/b] a[], int[b][color=Red]&[/color] [/b] b[]); #import

int init(){ double foo[2];[color=SeaGreen] // define pair of doubles[/color] int bar[2]; [color=SeaGreen]// define pair of integers[/color]

foo[0] = 1.23; foo[1] = 4.56;

bar[0] = 42; bar[1] = 23;

VarsByReference(foo, bar);

[color=SeaGreen]// print the changed values[/color] Print(foo[0]); Print(foo[1]); Print(bar[0]); Print(bar[1]); }

int start(){ }

3. Giving the DLL access to all bars in the chart

mql4 has two interesting functions: ArrayCopyRates() and ArrayCopySeries(). These functions, when applied to an empty array, do something interesting with it. Despite the name "copy" they don't actually copy anything, instead they replace the array entirely with something different and very interesting: Once you have applied one of these functions to an array variable, this variable will from now on behave exactly like one of the built-in arrays Time[], Open[], High[], Low[], Close[], Volume[]. It will automatically update when new ticks come in and if you now pass such an array by-reference to your DLL your DLL will receive a pointer to a memory location containing always up to date quotes.

We will use ArrayCopyRates() since this will give us the pointer to a 2-dimensional array, containing time and OHLCV for every bar in the chart.

There is only one noteworthy thing: in mql these series arrays always start with 0 being the current bar, in reality when accessing the memory directly in our DLL, it starts with 0 being the oldest bar and we need to pass an additional parameter to tell the DLL how many bars there are in total so it can figure out which one is the current one. (The array has no upper bound but values beyond the current index (Bars-1) are undefined and meaningless.)

The following example will calculate a simple moving average over the last 14 close prices to illustrate this concept, the mql4 EA will call this function and plot an arrow into the chart at the calculated price:

Inserted Code

[b]library[/b] testlib;

[color=MediumTurquoise]{$mode objfpc} {$H+}[/color]

[b]type[/b] [color=SeaGreen]{ MT4 stores the data of each candle in such a structure. MT4 will then give us a pointer to an array of such candles. NOTE the unconventional order: open, [b]low, high[/b], close, volume instead of OHLCV, this might be wrong in some of the other examples, I noticed it too late, please check your code. This here is the correct definition }[/color] TCandle = [b]packed record[/b] time: LongInt; [color=SeaGreen]// POSIX timestamp[/color] open, low, high, close, volume: double; [b]end[/b];

[color=SeaGreen]{ the following would be a pretty large array but we actually never cre ate an instance of it, we only need a typed pointer to such an array.}[/color] THistory = [b]array[/b][0..MaxLongInt [b]div[/b] SizeOf(TCandle) - 1] [b]of[/b] TCandle ; PHistory = ^THistory;

[color=SeaGreen]{ this function demonstrates how use such a PHistory pointer. Note that unlike in MT4 the array is indexed with 0 being the OLDEST and history_size - 1 being the CURRENT bar.}[/color] [b]function[/b] movingAverage(history: PHistory; history_size: LongInt; period: LongInt): Double; stdcall; http://www.forexfactory.com/showthread.php?t=219576 3/9 5/4/2014 Creating Metatrader DLLs with Lazarus / Free Pascal @ Forex Factory and in mql4:

Inserted Code

#import "testlib.dll" double movingAverage(double& history[][6], int history_size, int period); #import

double history[][6];

int init(){ [color=SeaGreen] // This won't actually copy anything, instead it // will make the array point to a metatrader // data structure where all candles are stored. // You only need to do this once, new candles will // be added automatically as time goes by.[/color] ArrayCopyRates(history, NULL, 0); }

int start(){ [color=SeaGreen] // Bars will always contain the number of usable // candles in our array. The DLL needs it to // determine the index of the current bar, because // in reality (outside of MQL4) this array starts // with 0 being the oldest bar and Bars-1 the current.[/color] double ma = movingAverage(history, Bars, 14);

[color=SeaGreen] // draw an arrow at our calculated average price[/color] string name = "arrow_" + Time[0]; ObjectCreate(name, OBJ_ARROW, 0, Time[0], ma); ObjectSet(name, OBJPROP_ARROWCODE, 4); ObjectSet(name, OBJPROP_PRICE1, ma); }

This is only an example to demonstrate how to access the bars in the chart. See Post #48 in this thread for a more complete version that properly uses an indicator buffer the way indicators are supposed to be written and indicator buffers are supposed to be used.

Mar 14, 2010 1:59am Quote Post 2 Time28 | Joined Jan 2010

Hi 7bit,

many thanks for that. Is it possible that you give us some more examples ?

Thanks for your help man!

Regards Time

Mar 14, 2010 11:42am Quote Post 3 Cdavid | Joined Apr 2008

I agree. More examples would be great

Mar 14, 2010 2:15pm Quote Post 4 sangmane

Wowww, great info!!! will download lazarus soon. i used to be using , mainly for application. mql <-> pascal thank you 7bit

Mar 24, 2010 2:11pm | Edited at 4:29pm Quote Post 5 Graff | Joined May 2009

Hi there. I' like to share a small function for correlation calculation in Lazarus. I ported this fuction from mql4(Original code here. Use google to translate it in your languge from russian languge). I ran caculation on multiple TFs and instruments so while calculation my terminal hanged for a few seconds. After rewriting this function on Lazarus calculations are seamless now.

Lazarus code: PHP Code:

http://www.forexfactory.com/showthread.php?t=219576 4/9 5/4/2014 Creating Metatrader DLLs with Lazarus / Free Pascal @ Forex Factory

library project1;

{$mode objfpc} {$H+}

type { MT4 stores the data of each candle in such a structure. MT4 will then give us a pointer to an array of such candles} TCandle = packed record time: integer; // POSIX timestamp open, high, low, close, volume: double; end;

{ the following would be a pretty large array but we actually never create an instance of it, we only need a typed pointer to such an array.} THistory = array[0..MaxInt div SizeOf(TCandle) - 1] of TCandle; PHistory = ^THistory;

{ this function demonstrates how use such a PHistory pointer. Note that unlike in MT4 the array is indexed with 0 being the OLDEST and history_size - 1 being the CURRENT bar.} function correlation(history_s1: PHistory; history_s2: PHistory; hs1: integer; hs2: integer; n: integer): double var sx,sy,x,y,cor1,cor2,cor3: double; i: integer; begin sx:=0; sy:=0; MQL4 code: for i := 1 to n do // i=1 is the current bar (history_size - 1)! P H Pb eCgoidne : x:=0; #import "project1.dll" double correlation(double& hist_s1[][6],double& hist_s2[][6], int hs1, int hs2, int bn); y:=0; x:=(history_s1^[hs1 - i].open+history_s1^[hs1 - i].close+history_s1^[hs1 - i].high+history_s1^[hs1 - i]. double history_s1[][6]; y:=(history_s2^[hs2 - i].open+history_s2^[hs2 - i].close+history_s2^[hs2 - i].high+history_s2^[hs2 - i]. double history_s2[][6]; sx+=x;sy+=y; end; ...

sx/=n;sy/=n; int start() cor1:=0;cor2:=0;cor3:=0; {

for i := 1 to n do // i=1 is the current bar (history_size - 1)! Comment(MTF_MS_Correlation("EURUSD"// Symbol 1 begin ,"USDCHF"// Symbol 2 x:=0; ,15// Period y:=0; ));

x:=(history_s1^[hs1 - i].open+history_s1^[hs1 - i].close+history_s1^[hs1 - i].high+history_s1^[hs1 - i]. //---- y:=(history_s2^[hs2 - i].open+history_s2^[hs2 - i].close+history_s2^[hs2 - i].high+history_s2^[hs2 - i]. return(0); } cor1+=(x-sx)*(y-sy); cor2+=(x-sx)*(x-sx); cor3+=(y-sy)*(y-sy); double MTF_MS_Correlation(string s1, string s2, int tf) end; { result := cor1/Sqrt(cor2)/Sqrt(cor3); //---- int n = 20; end; int hs1 = ArrayCopyRates(history_s1, s1, tf); int hs2 = ArrayCopyRates(history_s2, s2, tf); exports if(!hs1 || !hs2 || hs1<=n || hs2<=n){ Print("ArrayCopyRates on " + s2 + " TF " + tf + " failure!"); return(0 correlation;

//---- begin return(correlation(history_s1,history_s2, hs1,hs2,n)); end. } 7bit thanks a lot.

Apr 6, 2010 7:26am Quote Post 6 Relative | Joined Apr 2010

Hi 7bit, !

I'm a beginner Lazarus user. I wanted to try out the first example. So, I installed the Lazarus IDE...

Then - I created a new Project: 'click on Project -> new project -> Library'. - Copied the Pascal code to the Source Editor window. - I saved the project to an empty folder. (I got the two files: .lpi and .lpr) - I ran the Quick compile. I got other files: .compiled, .exe, .ico, .manifest, .o, .rc. And I got a backup folder too.

But there isn't any DLL file! Where is it?

When I run the Quic compile, I got these error messages too: http://www.forexfactory.com/showthread.php?t=219576 5/9 5/4/2014 Creating Metatrader DLLs with Lazarus / Free Pascal @ Forex Factory

Quote minimal(1,1) Warning: Relocatable DLL or executable minimal debug info does not work, disabled. minimal(1,1) Warning: To allow debugging for win32 code you need to disable relocation with -WN option Project "minimal" successfully built.

So, what can I do for creating my dll file? How can I disable the mentioned relocation with the -WN option?

Do you have any idea? What can I do? I would be happy, if you could help me.

(I use Windows 7 64bit . But I got the same messages with 32bit Windows XP SP2 too.)

Thank you in advance.

Relative

Apr 6, 2010 8:20am | Edited at 8:42am Quote Post 7 7bit

Quoting Relative I got other files: .compiled, .exe, .ico, .manifest, .o, .rc. And I got a backup folder too.

But there isn't any DLL file! Where is it?

This shouldn't happen. If the first line reads library and not program then it should create a .dll and not an .exe.

I'm currently not at my windows PC where lazarus is installed so i currently can not try out a few ideas i have about what might have gone wrong at your side, but usually it should create a dll without any problems.

Also you shouldn't use quick-compile but build instead. Delete everything except the lpi and the lpr files and then try again.

Which version of lazarus did you donwload? Is it the stable release or one of the snapshots? I personally always use one of the latest snapshots to always have all the newest bleeding edge features but these are not guaranteed to be bug free. I haven't used the official stable release for a long time, so maybe some minor details might be different but the general behaviour must be the same. the first line in a pascal program tells it what type of file it is, program is for .exe, library is for .dll and unit would be a separate module of source code you can later use in other projects and refer to it with the uses clause.

Apr 6, 2010 8:40am | Edited at 9:29am – aditional comment: This works! Quote Post 8 Relative | Joined Apr 2010

Quoting 7bit This shouldn't happen. If the first line reads library and not program then it should create a .dll and not an .exe.

I'm currently not at my windows PC where lazarus is installed so i currently can not try out a few ideas i have about what might have gone wrong at your side, but usually it should create a dll without any problems.

Which version of lazarus did you donwload? Is it the stable release or one of the snapshots?

Thank you for your fast reply.

I installed Lazarus 0.9.28.2 (lazarus-0.9.28.2-fpc-2.2.4-win64.exe) to my 64bit Windows 7 and the 32bit version (lazarus- 0.9.28.2-fpc-2.2.4-win32.exe) to the XP SP2.

About Lasarus info say:

Version #: 0.9.28.2 beta Date: 2009-10-26 FPC Version: 2.2.4 SVN Revision: 22279 x86_64-win64-win32/win64

Hm! So, this is a beta version? It seems... I looking for a non-beta version...

Anyway, in Lazarus, when I push the F9 (Run), I get this message:

Quote Project "minimal" successfully built.

and a Debug error popup window with this text:

Quote Debug error

Ooops, the debugger entered the error state Save your work now !

Hit Stop, and hope the best, we're pulling the plug.

[OK] http://www.forexfactory.com/showthread.php?t=219576 6/9 5/4/2014 Creating Metatrader DLLs with Lazarus / Free Pascal @ Forex Factory

Quoting 7bit Also you shouldn't use quick-compile but build instead. Delete everything except the lpi and the lpr files and then try again.

This works!

You were right! I shouldn't use quick-compile but build instead.

Thank you 7bit for your help and your examples!

Apr 6, 2010 10:32am | Edited at 10:44am Quote Post 9 7bit

Quoting Relative Hm! So, this is a beta version? It seems... I looking for a non-beta version...

It seems the Lazarus core developers suffer from the same symptoms that every perfectionist in software development has if there is no marketing department that steps in and dictates a version number bigger than 1.

The perfectionist's way of version numbering reflects his striving for perfection (which of course can never be reached) and the maturity of the project can be measured by the number of 9's and 8's that appear in the version number while it is asymptotically nearing (but never reaching) the 1.0 mark.

The compiler itself (actually a separate project) is already at 2.x and Lazarus would have deserved the formal 1.0 already 5 years ago. The "beta" or the 0.x doesn't mean anything. Its a only a gigantic understatement by the developers who probably would not even call it 1.0 if some day the bug tracker would be completely empty (which will of course never happen) because they would still have new ideas that are not yet implemented.

The same phenomenon can be observed with projects like mplayer or wine that have been around and are stable and mature for many years now and still carry a version number below 1.

This is the reason why I don't care about the version number anymore, I just use one of the recent builds that proves to be stable enough for me and if I still find a bug in the IDE or the LCL that affects me I try a new snapshot until find one that works for me or try to fix the bug on my own.

Apr 6, 2010 1:19pm Quote Post 10 Relative | Joined Apr 2010

Quoting 7bit This is the reason why I don't care about the version number anymore, I just use one of the recent builds that proves to be stable enough for me and if I still find a bug in the IDE or the LCL that affects me I try a new snapshot until find one that works for me or try to fix the bug on my own.

I used to use the latest versions too if I can.

___

Now, I have new problem.

So, my minimal.dll file is ready. I copied it the 'MetaTraderexpertslibraries' folder. I made the corresponding MetaTrader script file.

When I executed it in the MetaTrader, I got this error message:

Quote 2010.04.06 18:41:42 minimal_script EURUSD,M1: cannot load library 'minimal.dll' (error 126)

It's something like when the dll file miss or it's in a wrong directory.

Do you know why it is this error message?

Apr 6, 2010 2:39pm | Edited at 2:59pm Quote Post 11 7bit

Quoting Relative It's something like when the dll file miss or it's in a wrong directory.

126 means it cannot find the dll file. You placed it in the wrong folder or didn't spell its name correctly. It must be in the folder c:/program files/metatrader 4/experts/libraries/ or in c:/program files/metatrader 4/ or in c:/windows/system32 for mt4 to find it.

alternatively you can give the full path name to the dll in the #import directive, for example

#import "c:/foo/bar/somewhere/minimal.dll"

but this is not recommended, this only leads to problems and breaks things if you move folders around.

#import "minimal.dll"

should be sufficient and the dll must be in the experts/libraries/ folder

[the forum here doesn't like backslash, so I use forward slash instead] http://www.forexfactory.com/showthread.php?t=219576 7/9 5/4/2014 Creating Metatrader DLLs with Lazarus / Free Pascal @ Forex Factory

Apr 6, 2010 3:39pm | Edited at 4:18pm Quote Post 12 Relative | Joined Apr 2010

Quoting 7bit 126 means it cannot find the dll file. You placed it in the wrong folder or didn't spell its name correctly.

Yes, I know. But, it is in the right folder. Other dlls in the same folder work properly.

I just found this topic with similar problem: What can cause 'cannot load library mylib.dll (error 126)'?

...But it couldn't help.

I tried it on Windows XP too. I got the same 'cannot load library' message.

Apr 6, 2010 4:53pm Quote Post 13 7bit

Quoting Relative I tried it on Windows XP too. I got the same 'cannot load library' message.

Sorry, but I have absolutely no idea what you are doing wrong. Error 126 clearly says that it cannot find the dll file, there is no other possible interpretation.

The dll itself has no other dependencies, everything it needs is statically linked, if it can find the dll then it will be able to load it. Maybe you have 2 metatrader installations and accidentially used the wrong one? Maybe you created a link instead of copying the file (this often happens to beginners)? Maybe a problem with file permissions? I have no idea. All my examples were tested and worked before i posted them here. You must be doing something wrong.

Apr 6, 2010 5:27pm Quote Post 14 7bit

one thing i forgot:

You may of course not compile it for 64 bit and then use that dll with metatrader which is a 32 bit application (even on windows 64 bit). Maybe you compiled the dll for the 64 bit architecture and used that dll? For metatrader you must use the 32 bit version of lazarus and fpc. (you can cross compile but that may need some additional setup, so better simply install the 32 bit version).

Maybe I should write this into the first posting. I thought this was self-evident.

Apr 6, 2010 5:54pm Quote Post 15 ecTrade | Joined Jul 2009

Hey, cool. Does this mean you can create a library and share information back and forth between two separate accounts? This is what I downloaded here, and it's supposed to be able to do that. I may check it out here shortly. Except now I'm not sure the hedge option I was trying to setup is going to work, in which case there may not be any point. It would be interesting to see how it works though.

Apr 6, 2010 6:36pm Quote Post 16 7bit

Quoting ecTrade Hey, cool. Does this mean you can create a library and share information back and forth between two separate accounts?

I havent tried this yet with 2 metatraders loading the same dll but theoretically it should work if you place it in the system32 folder where both mt4s can access it.

Apr 7, 2010 2:25am Quote Post 17 Relative | Joined Apr 2010

Quoting 7bit I havent tried this yet with 2 metatraders loading the same dll but theoretically it should work if you place it in the system32 folder where both mt4s can access it.

You can share the folders and the files in it too with Link Shell Extension. For example I have six-seven MetaTrader installed with same 'experts' folder.

Quoting 7bit You may of course not compile it for 64 bit and then use that dll with metatrader which is a 32 bit application (even on windows 64 bit). Maybe you compiled the dll for the 64 bit architecture and used that dll? For metatrader you must use the 32 bit version of lazarus and fpc. (you can cross compile but that may need some additional setup, so better simply install the 32 bit version).

This is important information! I never thought I must use the 32 bit version when the 64 bit version exists. I will try it out... Thank you the idea!

Apr 7, 2010 8:22am Quote Post 18 http://www.forexfactory.com/showthread.php?t=219576 8/9 5/4/2014 Creating Metatrader DLLs with Lazarus / Free Pascal @ Forex Factory

ecTrade | Joined Jul 2009 Quoting 7bit I havent tried this yet with 2 metatraders loading the same dll but theoretically it should work if you place it in the system32 folder where both mt4s can access it.

Apparently, according to the files I downloaded (the instructions), it should work if you place a copy of the DLL in each of the library folders on each MT4 account.

Apr 7, 2010 8:59am Quote Post 19 7bit

Quoting ecTrade Apparently, according to the files I downloaded (the instructions), it should work if you place a copy of the DLL in each of the library folders on each MT4 account.

I don't know if windows would regard these two dlls as the *same* dll and load it only once. And even if it did (what i don't believe), what would happen if the two dlls would be slightly different? I don't believe windows would allow such things. If you want both to load the same dll then simply put it into the place that is meant for *shared* libraries: c:/windows/system32/

Maybe the example you are talking about is using entirely different methods for IPC, shared memory for example?

Apr 7, 2010 11:53am Quote Post 20 Relative | Joined Apr 2010

Quoting 7bit For metatrader you must use the 32 bit version of lazarus and fpc.

It works!

Thank you very much 7bit!

0 traders viewing now

More

Top of Page

Open Live Open Live Open Live Open Live Open Demo Open Demo Open Demo Open Demo

Tight spreads, quality execution, World class trading conditions At xm.com execution matters. Your trades, our technology. immediate settlement. Only... and infrastructure as well as… MT4 with no requotes... Your trade matters at IBFX...

Website Products Company Connect

Homepage Forums About FF Search Trades FF Blog Members Calendar Careers at FF User Guide News Advertising Report a Bug Market Contact FF Brokers ©2014 Forex Factory, Inc. / Terms of Use / Trade Explorer Privacy Policy Forex Factory® is a registered trademark.

http://www.forexfactory.com/showthread.php?t=219576 9/9