Intro
If for some reason you want pass values (like ask or bid) and receive answer (like sell or buy) from Forex Metatrader 4 to PHP or any other script language, there are two approaches:
- Call web server script (describe here)
- Execute command line script
Calling web server script, each time tick occurs might run out of free web server slots or even worse - lead out of free TCP ports in heavy testing situations, like strategy testing. Another approach, less resource intensive - to pass values to PHP and receive answer back to Forex Metatrader 4 expert is by calling external script using CLI. The only thing you have to aware is growing number of connection to MySQL (if you are using such).
Both methods work much slower as native MQL4 code. This might be an issue only while testing experts. In real trading I have not observe it as a problem (execution time is about 10 .. 50ms), other parameters like "slippage" during sharp market movements might provide even bigger headache.
How it works?
It is just an external library (DLL) allows your Forex Metatrader 4 expert communicate to PHP (or any other scripting language). So, if you are looking for expert or even Holy Grail - it is not here, at least not now :)
Future adjustments should be done in file fxphp.mq4How to install
- Open Metatrader folder (ex: c:\Program Files\Alpari)
- Extract content of archive into folder "experts"
- Adjust metatrader properties, allowing to run external DLL
- From Naviagator view drag and drop expert to chart
Most probably you will have to adjust path to PHP CLI (and PHP itself, if not yet done) and path to PHP script (callback.php). In my case path to PHP is set as system path, and PHP script located d://wamp//www//fx//callback.php.
Once it done and expert compiled, in Expert console you will get following messages. It is a ping back from PHP script
2012.03.20 02:05:21 fxphp EURUSD,M30: 2012.03.20 02:05:21;EURUSD;1.32293000;1.32306000
If something went wrong, please check FAQ section or use discussion bellow.
blog comments powered by Disqus