Download MetaTrader 5

Current price incorrect when using Tester

To add comments, please log in or register
Sneck55
110
Sneck55 2016.10.27 14:29 

I have been testing an EA using "Daily" period for July 2016. My EA needs the current market price in order to make buy/sell decisions and it works that price out by signing Bid to a variable after using RefreshRates(). In addition, my EA takes the high and low of the last hourly bar (after working out if it is a new hourly bar or not) using iHigh(NULL,PERIOD_H1,1) and assigns those to two variables then prints them. The hourly high and low in the EA agree precisely with High and Low on the Data Window so I think are correct. However I have tried printing the current price variable with Bid assigned to it (a lot of data even for 3 days) and the results show that the price being assigned to it cannot possibly be correct, for example none of the prices recorded in the current price variable were between the hourly high/low during the whole of that morning, let along during that hour! However the current price variable did rise to somewhere between the hourly high/low later that day (although by that time the bars on the chart had changed again of course). 

 

I have checked that my time settings on the PC are current and in the correct time zone and I don't seem to be getting the problem when running the EA live. However the Tester is obviously producing incorrect and very misleading and unusable results. Is there some reason why the Tester is getting the current Bid price very wrong?

Fernando Carreiro
2290
Fernando Carreiro 2016.10.27 18:02  

You have not shown your code, so we cannot check it for bugs!

When testing multi-timeframe EA, the strategy tester gets is current time-frame data from the FXT files, but for other time-frames it gets it from the HST files. If these mismatch and are not in sync and consistent with each other, you will get discrepancies. So, to clarify, please answer the following:

Is your FXT data being produced by MetaTrader or are you using a 3rd party tool like TickStory.

  • If your data is being produced by MetaTrader, are then any "mismatch" errors/warnings in the journal/log when it first runs and produces the FXT files?
    If yes, there are "mismatch" warnings, then your HST Files (History data) is not in sync and needs to be cleaned up.

  • If your data is being produced by 3rd Party tools, then you must produce both FXT and HST files and make them all read-only, both the FXT and HST files. If you don't do that, then incoming broker data will corrupt the files and cause mismatching data.
Sneck55
110
Sneck55 2016.10.27 21:58  
FMIC:

You have not shown your code, so we cannot check it for bugs!

When testing multi-timeframe EA, the strategy tester gets is current time-frame data from the FXT files, but for other time-frames it gets it from the HST files. If these mismatch and are not in sync and consistent with each other, you will get discrepancies. So, to clarify, please answer the following:

Is your FXT data being produced by MetaTrader or are you using a 3rd party tool like TickStory.

  • If your data is being produced by MetaTrader, are then any "mismatch" errors/warnings in the journal/log when it first runs and produces the FXT files?
    If yes, there are "mismatch" warnings, then your HST Files (History data) is not in sync and needs to be cleaned up.

  • If your data is being produced by 3rd Party tools, then you must produce both FXT and HST files and make them all read-only, both the FXT and HST files. If you don't do that, then incoming broker data will corrupt the files and cause mismatching data.
I don't know whether the data comes from my broker or from Metatrader - it just gets downloaded from somewhere automatically when required (I have always assumed it came from my broker but I could be wrong). I have noticed unmatched data errors in the Journal but I don't know what FXT data are. I have had other problems with missing data in the past, for example, days missing in the daily history. I have had problems with cleanliness and accuracy after deleting and downloading data in the History Centre in the past because sometimes two or three lines remain after deletion and it is necessary to repeat the process. How can I overcome this problem please?  As far as the code is concerned I am simply assigning Bid to a variable then printing it and using it to make decisions. The prints have revealed the inaccuracies. In other words Bid is not accurate and sometimes wrong by hundreds of points. Thank you.
Keith Watford
Moderator
9639
Keith Watford 2016.10.27 23:25  

I have noticed that sometimes the time in the tester journal is incorrect, I haven't noticed this for a long time though.

Print the bar time to make sure.

Sneck55
110
Sneck55 2016.10.28 08:05  
GumRai:

I have noticed that sometimes the time in the tester journal is incorrect, I haven't noticed this for a long time though.

Print the bar time to make sure.

The bar times using TimeCurrent() are the same as the bar times listed in the journal and within the time of the hourly bar. However the Bid price is outside the high/low price range of that hourly bar (as detailed above). Maybe MT4 is unstable.
Fernando Carreiro
2290
Fernando Carreiro 2016.10.28 11:16  
Sneck55:
The bar times using TimeCurrent() are the same as the bar times listed in the journal and within the time of the hourly bar. However the Bid price is outside the high/low price range of that hourly bar (as detailed above). Maybe MT4 is unstable.

No, it is not MT4 that is unstable. I have already stated that if you are getting "mismatch" errors, then your data is not in sync (or corrupt) and you will have to correct that.

Use the "PeriodConverter.mq4" to rebuild clean synced HST files from an M1 base, downloaded from the History Center.

Sneck55
110
Sneck55 2016.10.28 13:47  

I attached "PeriodConverter.mq4" to the M1 chart and opened the offline chart upon which MT4 crashed!

To add comments, please log in or register