Download MetaTrader 5
To add comments, please log in or register
How to launch your trading signal and become a provider
Frederic Seemann
14
Frederic Seemann 2013.11.20 12:29 

Hi everyone,

I just created an DLL and 2 EAs to exchange Quotes between the two terminals.

In the DLL i defined four variables:

double forexcom_eurusd_bid, forexcom_eurusd_ask, gkfx_eurusd_bid, gkfx_eurusd_ask;

Everything works fine and I can place the values from one terminal in the DLL in the respective variable and they can also be accessed again from the terminal which put the data in the DLL.

However, it is not possible to access the data from terminal A by terminal B. The variables are just empty.

How can I set the variables in the DLL global, so that they can also be accessed by the other terminal?

I attached the mq4. And this is the source code of the cpp:

#include "stdafx.h"

#define _DLLAPI extern "C" __declspec(dllexport)

double forexcom_eurusd_bid, forexcom_eurusd_ask, gkfx_eurusd_bid, gkfx_eurusd_ask;

/**
* ##
*/
_DLLAPI void forexcom_quote_uebergeben(double bid, double ask)
{
forexcom_eurusd_bid = bid;
forexcom_eurusd_ask = ask;
}

/**
* ##
*/
_DLLAPI void gkfx_quote_uebergeben(double bid, double ask)
{
gkfx_eurusd_bid = bid;
gkfx_eurusd_ask = ask;
}

/**
* ##
*/
_DLLAPI double forexcom_bid_zurueckgeben()
{
return (forexcom_eurusd_bid);
}

/**
* ##
*/
_DLLAPI double forexcom_ask_zurueckgeben()
{
return (forexcom_eurusd_ask);
}

/**
* ##
*/
_DLLAPI double gkfx_bid_zurueckgeben()
{
return (gkfx_eurusd_bid);
}

/**
* ##
*/
_DLLAPI double gkfx_ask_zurueckgeben()
{
return (gkfx_eurusd_ask);
}

Thank you already in advance.

Best regards,

Freddy

Files:
test1_1.mq4 1 kb
Sergey Sartakov
1286
Sergey Sartakov 2013.11.20 13:15  

How can I set the variables in the DLL global, so that they can also be accessed by the other terminal?


DLL for each terminal has its own variables than have nothing to do with others terminal's DLL variables.

You should organise shared memory in which all terminal's DLL will have access.

But it is not all, you also should synchronize the access to variables in shared memory from terminal's DLL, mutex objects or something like it...

I can give you some code example if you want.

Ian Flanagan
549
Ian Flanagan 2013.11.20 14:00  
more:


DLL for each terminal has its own variables than have nothing to do with others terminal's DLL variables.

You should organise shared memory in which all terminal's DLL will have access.

But it is not all, you also should synchronize the access to variables in shared memory from terminal's DLL, mutex objects or something like it...

I can give you some code example if you want.


please give some examples :)
Sergey Sartakov
1286
Sergey Sartakov 2013.11.20 14:40  
alladir:

please give some examples :)


Here is main DLL file from my Quotes Server/Client project:

 cQuotesProcDLL.cpp  - file too large to show here, so see arcive that is attached.

Each Terminal' DLL has own variable gpk_SharedMem that is initialised to point to DLL's shared memory.

DLL that starts first create this shared memory, others DLL will open this shared memory.

To sincronise access to shared memory from terminal' DLL each DLL has mutex object thet is in it's address space - gh_Mutex.

DLL that starts first create this mutex object, others DLL will open this mutex object.

All remaines this project files are attached as arcive.

Files:
Ian Flanagan
549
Ian Flanagan 2013.11.20 14:48  

Wow man, what a hero!

It's a little beyond me right now but this will speed up my study no end! Thanks!

I just finished a triangular arbitrage strategy in a dll and comparing quotes between brokers is my next step.

Forex
3
Forex 2013.12.05 15:57  
#define BufferSize 255
#pragma data_seg (".shareSEG")
char SwapString[BufferSize] = {'\0'};
#pragma data_seg()

#pragma comment(linker, "/Section:.shareSEG,rws")

try share segment to swap your data between 2 EAs.

/
To add comments, please log in or register