I need help with import dll

 

Hi,

I have compiled my matlab function into dll. In the EA, I put in the following code:

#import "MLfun01.dll"

double GetArrayItemValue(double ML_Signal[]);
ML_Signal[8] = MLfun01(string CP, string dataCL,double arr[8],string OTM);
#import

the output of the Matlab function is a 1x8 vector, so the output in MT4 from the function should be a 1x8 array. the above code doesn't work. Can anybody tell me what is the correct code of importing the dll for the function?

Thanks

 

Have you studied the sample dll? Your code is very confused.

/experts/samples

 
phy:

Have you studied the sample dll? Your code is very confused.

/experts/samples



Yes, I have. but I don't understand it. I need more explanation on it.

#import "ExpertSample.dll"
int GetIntValue(int);
double GetDoubleValue(double);
string GetStringValue(string);
double GetArrayItemValue(double arr[],int,int);
bool SetArrayItemValue(double& arr[],int,int,double);
double GetRatesItemValue(double rates[][6],int,int,int);
int SortStringArray(string& arr[],int);
int ProcessStringArray(string& arr[],int);


How will it be used in my case? Could you pls explain to me ? Thank you very much.

 
marshall318:
phy:

Have you studied the sample dll? Your code is very confused.

/experts/samples



Yes, I have. but I don't understand it. I need more explanation on it.

#import "ExpertSample.dll"
int GetIntValue(int);
double GetDoubleValue(double);
string GetStringValue(string);
double GetArrayItemValue(double arr[],int,int);
bool SetArrayItemValue(double& arr[],int,int,double);
double GetRatesItemValue(double rates[][6],int,int,int);
int SortStringArray(string& arr[],int);
int ProcessStringArray(string& arr[],int);


How will it be used in my case? Could you pls explain to me ? Thank you very much.

Or is it like this?

#import "MLfun01.dll"

double GetArrayItemValue(double ML_Signal[]);
bool SetArrayItemValue(double& ML_Signal[],int,int,double);
double MLfun01(string& CP,string& DataCl,double& v[],string& optm );

#import

 
marshall318:
marshall318:
phy:

Have you studied the sample dll? Your code is very confused.

/experts/samples



Yes, I have. but I don't understand it. I need more explanation on it.

#import "ExpertSample.dll"
int GetIntValue(int);
double GetDoubleValue(double);
string GetStringValue(string);
double GetArrayItemValue(double arr[],int,int);
bool SetArrayItemValue(double& arr[],int,int,double);
double GetRatesItemValue(double rates[][6],int,int,int);
int SortStringArray(string& arr[],int);
int ProcessStringArray(string& arr[],int);


How will it be used in my case? Could you pls explain to me ? Thank you very much.

Or is it like this?

#import "MLfun01.dll"

double GetArrayItemValue(double ML_Signal[]);
bool SetArrayItemValue(double& ML_Signal[],int,int,double);
double MLfun01(string& CP,string& DataCl,double& v[],string& optm );

#import

I call the matlab function from MT4 using the following:

v[] = {iCCI(NULL,240,14,0,0),iCCI(NULL,60,14,0,0),iCCI(NULL,15,14,0,0),iMACD(NULL,60,14,20,14,0,0,0)};
ML_Signal[] = MLfun01(Symbol(),"NetA2",v[],"E");

There are compile errors I don't know how to fix.

 

You are guessing.

Code a simple example and get it going first

Have Matlab add 2 numbers and return the value

#import "AddTwo.dll"
     int Add ( int a, int b);
#import
int x = 5;
int y = 10;
int start(){
     Print(" 2 + 3 = ", Add( 2, 3);
     Print(" x + y = ", Add( x, y);
     return(0):

}
 
phy:

You are guessing.

Code a simple example and get it going first

Have Matlab add 2 numbers and return the value

#import "AddTwo.dll"
     int Add ( int a, int b);
#import
int x = 5;
int y = 10;
int start(){
     Print(" 2 + 3 = ", Add( 2, 3);
     Print(" x + y = ", Add( x, y);
     return(0):

}
I got error 127 ...?
 
And error 127 is what?
 
phy:

And error 127 is what?

2008.02.06 08:56:20 cannot call function 'Add' from dll 'AddTwo.dll' (error 127)
 
Does your DLL export the function named Add ?
 
phy:

Does your DLL export the function named Add ?


I renamed the function from 'Add' to 'AddTwo', I still got the error 127. The following are the files generated from Matlab mcc command:

AddTwo.c, AddTwo.ctf, AddTwo.exports, AddTwo.h, AddTwo_mcc_component_data.c, AddTwo.dll, AddTwo.exp, AddTwo.lib

 #import "AddTwo.dll"
     int AddTwo( int a, int b);
#import
 
int start()
  {
//----
  
int x = 5;
int y = 10;
 
     Print(" 2 + 3 = ", AddTwo( 2, 3));
     Print(" x + y = ", AddTwo( x, y));
    
   return(0);
  }
Reason: