Create your own MetaTrader extension (dll) - page 9

 

For loop should be

for(int zz=MaximumRecords-1;.................

10 Records take positions 0 through 9 in an array

 
Tzuman:
For loop should be

for(int zz=MaximumRecords-1;.................

10 Records take positions 0 through 9 in an array

I'm afraid this hasn't helped, the DLL still doesn't update with new ticks.

 

Mistigri's sample video not available

Hi All,

Could someone make Mistigri's sample video available on the internet?

 
jocinet:
Hi All, Could someone make Mistigri's sample video available on the internet?

Mistigri made it available again at:

Projects | PsNouvion

 

A Path for C# Developers: MT4/5 -> C# DLL

Those C# developers who would like to write a DLL in C# for Metatrader instead of in C++ now have a path to that end. There is a very interesting article titled "Exposing C# code to MQL5 using unmanaged exports" that I've just read.

Read/skim the article and read section 2.5 onward.

Exposing C# code to MQL5 using unmanaged exports - MQL5 Articles

Read the directions, then download the Template for C# "Unmanaged Export Library" and place the zip file in the right directory (by following the directions on that page):

C# Project Template for Unmanaged Exports

Load VS and select the "Unmanaged Export Library" template. Follow the code samples. Hope this helps somebody!

 

critical error but no crash and this is how to write dll

Finally able to write my dll using MistigriFX Sample Debug (MFX_SD for short) on Visual Studio 2008 Express.

However I'm having a funny problem :

There's no problem when running three MFX_SD to the chart with different period input. However when attaching another three to the second chart with different period input, I'm having two error messages (function 'GetSMAArray' call from dll 'Mistigri FX Sample 1.dll' critical error') and the expert stop working.

So I see two chart, in one chart all three MFX_SD running well every tick, on another I see only one MFX_SD running every tick and the other two is not.

any advice guys ?

Attached is how I write the dll in visual studio 2008. I write this in text document so you can read it from your Visual Studio.

If you have any error please curse your self from following advice from novice programmer like me .

Many thanks in advance.

 

critical error solved

After tried several times, I finally solved the 'critical error' messages (read my previous post).

It's got nothing to do with the way I made the .dll, but it's got to do with miss logic in GetSMAArray function in MFX_SD codes.

Here's MFX_SD codes which I highlight the miss logic.

for ( int i = 0; i < MaximumRecords; i++)

{

double Sum = 0.0;

for ( int k = 0; k < Period ; k++ )

{

Sum += Rates[MaximumRecords-i-1-k].close;

}

Result[MaximumRecords-i-1] = Sum / Period ;

}

For example supposed we have Period = 2, MaximumRecord = 75, and i = 74. That makes error when calculating :

Sum += Rates[MaximumRecords-i-1-k].close;

because the result of MaximumRecord - i - 1 - k is equal -1. The only value for Rates [-1] is zero, that makes value of sum equal zero too. And since we calculate SMA we have to divide sum with Period, which is zero divided by 2, And there's the 'critical error' and the expert stops.

If you don't believe this, attach several MFX_SD to a 1 minute chart with different input period but one of MFX_SD must have input period = 1. Look at the MT Terminal window and click expert tab. You will see an critical error messages and the expert stops working. However if you look at the chart only MFX_SD with period = 1 is still running.

I think what MistigriFX trying to show in his video was how to make dll and passing arrays to dll. If he must correct in his SMA logic, it would be a video that seriously headache to watch. That's why he show us with not-correct but a simple example of simple MA.

Happy dll making.

 

MT4 extension- your course

Hello codersguru,

could you please give me some links to your course,

or pdf manual.

I would need any literature to learn more about it.

Many thanks.

Best regards

Ivan

 

...

In the experts\samples\DLLSample folder of metatrader (every metatrader installs it there) you have an example (mql and C++ source, with project and def file) that is all you need to know about dll calls (all the possible parameter types supported by metatrader to dll and back "communication" are covered there) The rest is up to your knowledge of C/C++.

holesovsky:
Hello codersguru,

could you please give me some links to your course,

or pdf manual.

I would need any literature to learn more about it.

Many thanks.

Best regards

Ivan
 

Great Help! Thanks!