Virtual Dealer Plugin

hyper

Corporal
Messages
93
Yes, I've always used journal or log so far to determine execution time and slippage.
This is unsatisfactory for two reasons: 1) the journal isn't permanent, so I'd have to copy/paste the info to a text file to have a lasting record
The log files are permanent, so you can use those.

2) both journal and log only state times in full seconds, so they aren't exactly precise.
It is disappointing that MetaQuotes does not have millisecond precision, but knowing that an execution took 1, 2, or more seconds is still useful, so millisecond precision is not essential.

In addition, the log does not provide prices for the request but only for the actual execution, which makes it useless to determine slippage.
It does provide the requested price, but on the first line (of the four lines). See my example above.

That is why I'd hoped for some instruction on how to use the code you've provided
There are many ways that my code could be used. They are just MQL functions that submits an order to open a trade, or closes an existing open trade. You can copy and paste either the entire functions into your own expert advisor or you can just copy some lines and paste them into your own order sending and closing code. This assumes of course that you have access to the code of the expert advisor.

If you want to record execution duration and slippage for manual trades, you could put the code into scripts. I've made an example in this post: http://www.forexpeacearmy.com/forex...er-execution-duration-slippage.html#post82836
 

PaladinFX

Private
Messages
26
No, the log does not provide requested prices, only actually executed ones ... that's the annoying thing.
Only the journal provides both prices requested and exectued ... and the journal is not permanent.
It's the main thing I don't like about MT ... data which can be used to monitor the platform's and broker's performances are insufficient.

That's where your code comes in handy ... thanks for the sample script in your linked thread; I'll try it out. :)

P.
 

hyper

Corporal
Messages
93
No, the log does not provide requested prices, only actually executed ones
The log does contain the requested price. It is in the first line of the four lines for each transaction.
Here are some further examples that I've just made, taken from the log file, with the requested price in bold font:

21:27:50 '438846': instant order buy 1.00 EURUSD at 1.3478 sl: 0.0000 tp: 0.0000
21:27:50 '438846': request was accepted by server
21:27:50 '438846': request in process
21:27:50 '438846': order was opened : #15110208 buy 1.00 EURUSD at 1.3478 sl: 0.0000 tp: 0.0000

21:28:04 '438846': close order #15110208 buy 1.00 EURUSD at 1.3478 sl: 0.0000 tp: 0.0000 at price 1.3474
21:28:04 '438846': request was accepted by server
21:28:04 '438846': request in process
21:28:04 '438846': order #15110208 buy 1.00 EURUSD at 1.3478 sl: 0.0000 tp: 0.0000 closed at price 1.3474


An alternative to recording execution duration and slippage in real-time would be to write code that parses the text of the journal log file so that the relevant data is formatted into a CSV file (or into spreadsheet cells via a VBA macro). It would then be possible to record execution duration and slippage for all trades made in the terminal regardless of whether trades were by an expert advisor or done manually.
 
Last edited:

PaladinFX

Private
Messages
26
That's weird, my log looks like this:

22:09:13 '142716': order sell market 0.57 GBPUSD sl: 0.00000 tp: 0.00000
22:09:13 '142716': request was accepted by server
22:09:13 '142716': order was opened : #13178857 sell 0.57 GBPUSD at 1.58995 sl: 0.00000 tp: 0.00000
22:09:13 Publisher: starting
22:09:13 '142716': modify order #13178857 sell 0.57 GBPUSD at 1.58995 sl: 0.00000 tp: 0.00000 -> sl: 1.59995 tp: 1.58915
22:09:14 '142716': request was accepted by server
22:09:14 '142716': order #13178857 sell 0.57 GBPUSD at 1.58995 was modified -> sl: 1.59995 tp: 1.58915
22:09:15 Publisher: ok

03:03:47 '142716': close order #13178857 sell 0.57 GBPUSD at 1.58995 sl: 1.59995 tp: 1.58915 at price 0.00000
03:03:48 '142716': request was accepted by server
03:03:48 '142716': order #13178857 sell 0.57 GBPUSD at 1.58995 sl: 1.59995 tp: 1.58915 closed at price 1.59173

That's an order opened and closed by an EA, using an ECN broker's demo account.
When opening, the first line doesn't contain a price at all; when closing, price is shown as 0.00000 (bold).

I've never paid much attention to logs before ... is it possible that logs of Market Execution trades are different from those of Instant Execution?


Cheers,
P.
 

hyper

Corporal
Messages
93
Your are right, the output varies depending on whether Instant or Market Execution is used. I had only been looking at the log of an Instant Execution broker.

I've just tried an order open and close at FinFX which uses Market Execution. Here's the log output:

10:37:03 '93491': order buy market 1.00 EURUSD sl: 0.00000 tp: 0.00000
10:37:04 '93491': request was accepted by server
10:37:04 '93491': request in process
10:37:04 '93491': order was opened : #13687863 buy 1.00 EURUSD at 1.33912 sl: 0.00000 tp: 0.00000

10:38:56 '93491': close order #13687863 buy 1.00 EURUSD at 1.33912 sl: 0.00000 tp: 0.00000 at price 0.00000
10:38:56 '93491': request was accepted by server
10:38:56 '93491': request in process
10:38:56 '93491': order #13687863 buy 1.00 EURUSD at 1.33912 sl: 0.00000 tp: 0.00000 closed at price 1.33847

So slippage cannot be derived from the Journal log if Market Execution is used.
 

PaladinFX

Private
Messages
26
I'm happy you've been able to confirm it ... I was beginning to doubt my broker, and my head, hehe.

All the more valuable is your code.
I'll educate myself about basic coding, so that I may incorporate it to open/close/modify orders.

P.

Edit/P.S.: Are you a professional programmer or a trader who has happened to learn MQL4?
 

hyper

Corporal
Messages
93
Are you a professional programmer or a trader who has happened to learn MQL4?
I've been a professional programmer for 11 years and have worked for some of the largest global corporations.

These days I program professionally in ASP.NET (VB & C#) for my own clients.

I've been programming since 2006 mostly for my own trading (and sometimes for other traders who offer to pay), mostly in MQL4 but also in Java for the JForex platform, VBA in Excel, C# for standalone applications and some C++ for DLLs to use in MetaTrader.
 
Last edited:

AsstModerator

FPA Forums and Reviews Admin
Messages
5,575
MetaQuotes wants the image on the first page of this thread removed. I have invited more than one of their employees to join this discussion and talk about the Virtual Dealer Plugin. They have all declined.

MetaQuotes representatives have threatened to take legal action against the FPA if the image wasn't removed from this thread. I told them no.

They filed a DMCA claim with the FPA. I explained why I believe the claim did not qualify under fair use guidelines.

They filed a second DMCA claim with the FPA's hosting company. This forced me to temporarily move the thread to a non-visible folder. The FPA challenged this claim. The hosting company has now given me the green light to put the thread back where it came from.
 
Top