MATLAB | MT4

 

I wrote a basic function in Matlab, this function outputs anythng that is inputted.

function co_int_function(c)
c


Using the Matlab compiler with the following instruction, 8 files were generated. 

mcc -W lib:dlltest -T link:lib co_int_function

The following files were generated, these files are attached in the zipped file.

dlltest.lib

dlltest.exp

dlltest.dll

dlltest_mcc_component_data.c

dlltest.ctf

dlltest.h

dlltest.exports

dlltest.c


When i load the dlltest.dll back into Matlab to see what function are available, the following shows up:

bool dlltestInitialize
[bool, lib.pointer, lib.pointer] dlltestInitializeWithHandlers(lib.pointer, lib.pointer)
dlltestTerminate
MATLAB array mlfCo_int_function(MATLAB array)


In MT4, i used the following commands to use the Matlab function:

#import "dlltest.dll"
double mlfCo_int_function(iint e2);
#import


MT4 throws the following error:

cannot call function 'mlfCo_int_function' from dll 'dlltest.dll' (error 127)


Matlab created standard DLLs, for some reason, i cannot execute it.

 


Files:
dlltest_files.zip  1376 kb
 
I attempted similar, made very simple matlab function double fc(double ) taht returns power, I use mqh file for function definition, then made into a indicator but all it does it throws uninit 1 and thats it outputs nothing...

 
c0d3:

I wrote a basic function in Matlab, this function outputs anythng that is inputted.


Using the Matlab compiler with the following instruction, 8 files were generated.

The following files were generated, these files are attached in the zipped file.

dlltest.lib

dlltest.exp

dlltest.dll

dlltest_mcc_component_data.c

dlltest.ctf

dlltest.h

dlltest.exports

dlltest.c


When i load the dlltest.dll back into Matlab to see what function are available, the following shows up:


In MT4, i used the following commands to use the Matlab function:


MT4 throws the following error:

cannot call function 'mlfCo_int_function' from dll 'dlltest.dll' (error 127)


Matlab created standard DLLs, for some reason, i cannot execute it.


I followed these same steps using Matlab R2010b and Visual Studio 2008 professional and do not get the error 127.

Maybe it is specific to the Matlab version you are using.

OTOH I am trying to work out how to pass the parameters to the mlfCo_int_function.

I assume iint is a misprint for int?

After you initialise first with dlltestInitialize the function call to mlfCo_int_function just crashes MetaTrader.

BTW I am aware this is an old thread but am adding my experiences for other people doing searches on MATLAB and MQL4.