DLL to exchange data between terminals

 

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
 

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.

 
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 :)
 
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:
 

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.

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

Reason: