Closed

C++ DLL for Metatrader 4: correct parameter passing syntax

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++.

Skills: C++ Programming, Metatrader

See more: dll metatrader, metatrader dll, dll mt4, mt4 struct, mt4 string, dll mq4, metatrader string, dev dll mt4, dev mq4, dll double mt4, mt4 dll char, dll output mt4, guide write dll metatrader, mq4 double, dll dev mt4, metatrader struct mqlstr, int parameter metatrader, mt4 indicator arrays dll, metatrader double dll, dll reference mt4, dll file mq4, metatrader syntax, mt4 string char, history metatrader, mq4 dll

About the Employer:
( 0 reviews ) Slupsk, Poland

Project ID: #1116775

2 freelancers are bidding on average £100 for this job

CreditGroup

pls check PMB

£100 GBP in 1 day
(14 Reviews)
4.8
mqldeveloper

Kindly Check PMB please. Thank you.

£100 GBP in 2 days
(2 Reviews)
2.5