Can MQL4 send and get Ask/Bid Values to/from Memory?

 

Dear!

I am newbie in this world of MQL, I have read almost all previous topics, but unable to find out exact answer

I just want to know that Can MQL4 send and get Ask/Bid Values to/from Memory (without physically creating files on the hardisk)?


1- Actually I want to transfer Ask/Bid Values to C++ (using memory)

2- after some manipulations in C++, then again transfer back to MQL4 for further procedures (using memory)


I shall be really grateful if someone can HELP me in this manner. examples of code will be really helpful



Thanks

THG

 

Why don't you use a dll which you wirte in C++?

Yout could either do your calculations in this dll or write to the memory ...

 

haemse is right.

Create C++ DLL module (name it MyModule.dll) with expoterd function like this:

extern "C" void __stdcall MyFunction(double a[])

{

double bid = a[0], ask = a[1];

// process these values some way and then set them back to a caller

a[0] = bid;

a[1] = ask;

}

(There is a sample C++ project within expert/samples/DLLSample folder showing how to create a C++ module for MT4)

Place MyModule.dll in experts/libraries folder.

Then in MetaEditor create header file named for example MyModule.mqh with following code in it:

#import "MyModule.dll"

void MyFunction(double& a[]);

#import

Then include this file in your script or expert and call the function:

#include <MyModule.mqh>

int start()

{

double a[2];

a[0] = Bid; a[1] = Ask;

MyFunction(a);

double new_bid = a[0], new_ask = a[1];

}

Don't forget to enable Tools/Options/Expert Advisors/Allow DLL imports checkbox!

 

Thanks Dears!

but this solution will only work if I will have one broker(MT4)

Actually, Let me give you a complete picture now, I want to manipulate ASK/BID values from multiple Brokers to a single C++ program and then based on calculations my C++ program will decide to send further commands to a single Broker

Now what I want:

1- I dont want to use File Handlings

2- I will prefer to send/get values from/to memory (only because its comparatively faster than simple file handling)


Regards

THG

Reason: