C++ DLL for Metatrader 4: correct parameter passing syntax
£20-250 GBP
Πληρώθηκε κατά την παράδοση
I would like to learn the correct syntax for passing arguments to a C++ DLL that will be called from a Metatrader 4 .mq4 file, and to receive the output from the DLL for plotting in an indicator and use by an EA. As a guide to what I would like see the thread on the forum at [url removed, login to view], but I want C++ and not Pascal.
Specifically, I would like the correct syntax for these (incorrect?) equivalents:
for the .mqh file
#import "[url removed, login to view]
void updateBuffer( double& history[][6], double& buffer[], int bars, int indicator_counted, int ma_period );
#import
for the .mq4 file
#import "[url removed, login to view]"
// history and buffer are passed by reference, this means the dll will receive pointers to the arrays
void updateBuffer( double& history[][6], double& buffer[], int bars, int indicator_counted, int period );
#import
double history[][6];
ArrayCopyRates(history, NULL, 0);
int start(){
updateBuffer( history, buffer, Bars, IndicatorCounted(), ma_period);
}
for the C++ DLL
#define WIN32_LEAN_AND_MEAN
#define MT4_EXPFUNC __declspec(dllexport)
//+-----------------------------------------------------------------------------------------------------------------------------+
//| MT4 HISTORY DATA STRUCT |
//+-----------------------------------------------------------------------------------------------------------------------------+
#pragma pack(push,1)
struct history { unsigned int ctm; double open; double low; double high; double close; double vol; };
struct MqlStr { int len; char * string; };
#pragma pack(pop)
//+-----------------------------------------------------------------------------------------------------------------------------+
MT4_EXPFUNC void _stdcall updateBuffer( double * history, double * buffer, int Bars, int IndicatorCounted, int ma_period )
{
in the main code I want the correct way to access the variables in history and to write output to buffer
}
The purpose of this project is for me to learn the relevant and correct coding syntax for future projects I have in mind rather than just recreating some online code. I will be using Dev-C++ 4.9.9.2 for my C++ compiling and I do NOT want code that is specific only to Visual Studio C++.
Ταυτότητα Εργασίας: #1116775