Hi there,
I have a tiny question and I hope someone here will be able and willing to help me out.
The basic issue is using external functions in MT4 via a DLL. My basic problem is that it doesn't work but doesn't give any errors either.
So let me be more specific:
I used the MATLAB C++ Shared Library to convert an m-file into a DLL. That worked fine. Then I wrote, or rather copied, a wrapper dll, which converts my input to the format understood by the matlab dll.
Anyway I end up having a dll which is supposed to provide one function
Code:
double GetMaxEigenValue( double s1, double s2, double s3 )
I define the function as
Code:
__declspec(dllexport) double _stdcall GetMaxEigenValue( double s1, double s2, double s3)
This should be fine.
In my .def file I have
Code:
LIBRARY "EV Arbitrage"
EXPORTS
GetMaxEigenValue
Ok. I then tried to test what I did so far by writing a simple c++ script which uses this function:
Code:
#include <iostream>
using namespace std;
double _stdcall GetMaxEigenValue(double s1, double s2, double s3);
void main(void)
{
double Ret = GetMaxEigenValue(5.,2.,3.);
cout << Ret;
}
This worked alright, giving me the impression that there is nothing wrong with my DLL.
However, now I tried to use the function from MQL4. SO that's what I did: I copied the dll, as well as the dll generated by matlab (not sure if that's necessary) into the experts/libraries folder, put the following script, "EV Arbitrage Library.mqh"
Code:
#import "EV Arbitrage.dll"
//double GetMaxEigenValue( double Rates1[][6], int MaximumRecords1, double Rates2[][6], int MaximumRecords2, double Rates3[][6], int MaximumRecords3, int z );
double GetMaxEigenValue( double s1, double s2, double s3);
#import
into the experts/include folder and tried the following in a Custom Indicator:
Code:
#include <EV Arbitrage Library.mqh>
...
Alert("before")
double val = GetMaxEigenValue(5.,2.,3.);
Alert("after");
Everything compiled just fine, but when I attached the indicator to a chart, it announced the first alert but not the second one. Everything behind the call to my dll seems to be geting evaluated.
I would appreciate any idea what I could be doing wrong If more code is needed I will provide it of course.
Thanks a lot
Pere