Create your own MetaTrader extension (dll) - page 7

 

DLLs and Indicators

Anyone have any types or general best practices for using a dll in an indicator (how to get the range of prices to the dll, etc)? I want to have a dll calculate the values instead of using functions in MetaTrader.

Thanks!

 

Page not found!

mistigriFX.com cannot be found anymore. what could be the reason?

 

How to make them work?

Mistigri:
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 :

EXPORTS

_Z11GetSMAArrayP8RateInfoiiPd@16 @ 1

_Z12GetHighValueP8RateInfoii = _Z12GetHighValueP8RateInfoii@12 @ 2

_Z12GetHighValueP8RateInfoii@12 @ 3

_Z13GetCloseValueP8RateInfoii = _Z13GetCloseValueP8RateInfoii@12 @ 4

_Z13GetCloseValueP8RateInfoii@12 @ 5

_Z11GetSMAArrayP8RateInfoiiPd = _Z11GetSMAArrayP8RateInfoiiPd@16 @ 6[/PHP]

Now you need to make sure you add the following check around your code

[PHP]

#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

how do we test those files?? what should we do? As far as i know, host applications for Dev C++ are only exe. How can we use the ex4?

 
xarlotie:
how do we test those files?? what should we do? As far as i know, host applications for Dev C++ are only exe. How can we use the ex4?

oh! what a very stupid question! sorry for this..i realized the answer to it..just ignore this post..thanks!

 
codersguru:
Anybody interested in creating his/her own MetaTrader extension (dll) may go to:

Create your own MetaTrader extension (dll) - Part 1

Create your own MetaTrader extension (dll) - Part 2

There'll be another part (or 2) which I'm writing them!

Hope you enjoy them!

Thanks a lot for

the article.

 
codersguru:
Anybody interested in creating his/her own MetaTrader extension (dll) may go to:

Create your own MetaTrader extension (dll) - Part 1

Create your own MetaTrader extension (dll) - Part 2

There'll be another part (or 2) which I'm writing them!

Hope you enjoy them!

I have tried to follow the steps:

Figure 2 - New project dialog

3- From this dialog choose "MFC AppWizard (dll)" and write a name for the project in the "Project Name" field (Figure 3) and click "OK".

However there is no such choice "MFC AppWizard (dll)"

I am using C++ 2008 express from MS

What am I doing wrong.

 

Hello no body help?

Any body can make tutorial for C++2008 please?

sub00:
I have tried to follow the steps:

Figure 2 - New project dialog

3- From this dialog choose "MFC AppWizard (dll)" and write a name for the project in the "Project Name" field (Figure 3) and click "OK".

However there is no such choice "MFC AppWizard (dll)"

I am using C++ 2008 express from MS

What am I doing wrong.
 
Mistigri:
Just finished a video on how to write a DLL for MT4 ... I tried to make an example that returns an array since it's really what I though was missing when I first started to look into the sample provided by MetaQuotes.

Watch Video

If you are only interested in the code and VS project, these can be downloaded Here.

Hope you like it

Patrick

Awesome video, just what I was looking for!

Much respect.

 

I've downloaded and compiled mistigri's project with VS++2008

The first two functions work fine, but the second one crashes the terminal just like in this article:

How to Use Crashlogs to Debug Your Own DLLs - MQL4 Articles

I get a C0000005 exception thrown ...

Exception : C0000005

Address : 77C36FA3

Access Type : read

I so far have not figured out what's wrong. Something having to do with the way the OutPut[] array is passed into the dll. Any input would be appreciated!

 

problem was too many bars per chart, here is the solution:

you can either set chart properties to display a reasonable amount bars per chart, like 1000 for example, or in code:

int start()

{

double Rates[][6];

int MaximumRecords = ArrayCopyRates( Rates, Symbol(), 0 );

if(MaximumRecords>1000)MaximumRecords=1000;

if(MaximumRecords>0)

{

ArrayResize(OutPut, MaximumRecords);

ArrayInitialize(OutPut, 0.0);

GetSMAArray( Rates, MaximumRecords, Periods, OutPut );

}

/*

for( int z = MaximumRecords-1; z>=0; z--){

//OutPut[z] = GetCloseValue(Rates, MaximumRecords, z);

OutPut[z] = GetHighValue(Rates, MaximumRecords, z);

}

*/

return(0);

}

Reason: