Basic DLL Question

 

Hi guys

New to signing up to the forum as have only just got stuck.

This question may be very simple and it may be that I have missed the answer in my search. I suspect the question is almost too basic to have been asked before?!

I have coded in C++ before but am a bit rusty. Finding MQL4 is ok and am picking it up. Have never touched DLLs before at all though and am totally lost! The DLL sample is way above my level!

I am aiming to store a number of variables in some shared memory via a DLL. I want two different MT4 instances to both be able to communicate simple variables like Bid and Ask with each other. I envisage having two MT4 windows passing their new tick prices to the DLL, then hoping both MT4s can "see" each others latest prices at all times?

I believe a DLL would be better than doing this via a text/csv file as it is quicker and allows simultaneous access? Am I right in saying this?

Thanks in advance for any help whatsoever!

Mark

 
yeah, what are you trying to do it's called "lag trading" ... quite illegal on all brokers ;)
 
csebastian:
yeah, what are you trying to do it's called "lag trading" ... quite illegal on all brokers ;)

What is lag trading? I'm trying to correlate movements across currency pairs, so if the USD instantly turns against a number of pairs then I'll view it as being overvalued. Thing is the broker who I want to trade with as it has the lowest spread does not have as many currency pairs as some other brokers...and I want to be able to view as many as possible. Does that make sense?

 

sounds like arbitrage to me and I don't think arbitrage is illegal

 

Agreed if arbing opportunites ever arose then it is not your fault they have mispriced surely? Not what I am planning though anyway, pretty sure with sippage and spreads you'd be struggling to see many arbing possibilities. Hey I'm all over it if it does occur though! ;)

Any further ideas with the DLL? Even if anyone can point me to a really really easy guide? :)

 
MarkSkov:

Any further ideas with the DLL? Even if anyone can point me to a really really easy guide? :)

With your experience in C++, the example DLL should only look intimidating. It's not actually doing anything complex.

By default, memory allocated by a DLL is shared between different threads of a single process, but not between different processes (i.e. separate instances of MT4). If you want to share memory across processes, you will either need to try something like shared data segments (e.g. http://www.codeproject.com/KB/DLL/data_seg_share.aspx) or use something like memory-mapped files.

Anything which is memory-based is obviously going to be faster than file access. On the other hand, file access offers at least some prospect of scaling things out across multiple machines. A really cute - albeit probably very excessive - solution would be to use something like memcache (http://memcached.org/).

 
jjc:

With your experience in C++, the example DLL should only look intimidating. It's not actually doing anything complex.

By default, memory allocated by a DLL is shared between different threads of a single process, but not between different processes (i.e. separate instances of MT4). If you want to share memory across processes, you will either need to try something like shared data segments (e.g. http://www.codeproject.com/KB/DLL/data_seg_share.aspx) or use something like memory-mapped files.

Anything which is memory-based is obviously going to be faster than file access. On the other hand, file access offers at least some prospect of scaling things out across multiple machines. A really cute - albeit probably very excessive - solution would be to use something like memcache (http://memcached.org/).


Like you say, perhaps it is just a lack of recent practice making it look worse than it is!

I did have a feeling I might be barking up slightly the wrong tree...really appreciate the answer as that will allow me to redirect my search for the right sort of example! Thanks! :)

I will post any answers I come up with here just so others can find it hoepfully.

 

Sounds interesting I have compared price feeds from 4 different brokers over a very short period of time just by veiwing some screen captures from different people on another forum who were discussing the price at market close one Friday a few weeks ago, in the 4 screen captures there were significant price differences over the 24hr bar period on the 15 minute chart some of those differences were as high as 14 pips.

Reason: