Discussion on "How to write a DLL for MQL5 and exchange data in 10 minutes". - page 5

 
mql5 писал(а)  :

1) which version of the terminal is 32 or 64 bit?

2) which version of dll is 32 or 64 bit?

1) is there a choice? I think only x86 downloads from here...

2) dll 32

 

Reinstalling MT5 gave the following result. When launching the script, the following info appears in the log Cannot find function fnCalculateSpeed in 'MQL5DLLSamples.dll'.

I am attaching a screenshot of the library from Dependency Walker just in case.

 
denkir:

Reinstalling MT5 gave the following result. When launching the script, the following info appears in the log Cannot find function fnCalculateSpeed in 'MQL5DLLSamples.dll'.

I am attaching a screenshot of the library from Dependency Walker just in case.

What is the build number of the re-installed terminal?
 
stringo:
What is the build number of the re-installed terminal?
Apparently old, not the latest 240 build.
 
Renat писал(а) :
Apparently old, clearly not the latest 240 build.

Yeah, definitely not the last one...

After upgrading to 240 bild the first run of the script worked fine. I got excited. But subsequent runs only resulted in a crash. MT 4 was running in parallel.

 

After rebooting, everything seems to be working! :-))

Commented out function fnCrashTest(int arr)

Thanks to all, who helped!

 
In general, I have not managed to increase calculation speed using dll by more than 2.5 times. This shows the high speed of MQL5, and for most trading tasks there is no sense to bother with dll, except when it is necessary to protect the code and when "heavy" calculations are needed.
 
joo:
In general, I have not managed to increase calculation speed using dll by more than 2.5 times. This demonstrates the high speed of MQL5. For the majority of trading tasks there is no point in bothering with dll, except when it is necessary to protect the code and when "heavy" calculations are required.

The final register optimization of MQL5 is not enabled yet - the speed of execution will still seriously increase.
 

Renat, thank you for the article. I think many people will need it more than once. I have a side question related to dll. (Terminal 249, Editor 248).

Example

We have a libra demo.dll with only one function.

_DLLAPI void __stdcall demo(char *stream, char *buf){ buf=stream;}

We have an mql script demo.mq5.

#property copyright "2010, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"

#import "demo.dll"
void demo(string s1, string &s2);
#import

void OnStart(){
   string a="TEST"; string b;
   demo(a,b);
   Print(b);    
}

The compiler doesn't show any errors or warnings.

Run it in the terminal and get the following

When checking in the visual debug, I also found out that the demo.dll function itself has its first character, not a string.

The question is

What's the problem? How to pass the string from MQL to dll in a human way?

 
Usewchar_t instead of char
Reason: