I've found that, at least when using ArrayCopyRates to send price data to a DLL,
the time field in the rate info records does not always have the expected contents.
In some cases, the times seem to skip one or more bars (in some cases hundreds
or thousands). I've even encountered a situation where the most recent tick on
a one-minute chart was supposedly about 77 days older than the tick before it! (That's how I found the issue - it was confusing the heck
out of a DLL I'm writing.)
Here's a C++ function I wrote to test and verify this problem:
#pragma pack(push,1)
struct MqlRateInfo
{
unsigned Time;
double Open;
double Low;
double High;
double Close;
double Volume;
};
#pragma pack(pop)
CORE_EXP void CORE_API ValidateRateTimes( MqlRateInfo const *paRates, int nBars, int Period )
{
int PeriodSecs = Period * 60;
FILE *pLogFile = fopen( "C:\\temp\\MetaTrader Bug.log", "w+" );
if( !pLogFile )
return;
fprintf( pLogFile, "Verifying %d %d-minute bars...\n", nBars, Period );
unsigned ExpectedTime = paRates->Time;
fprintf( pLogFile, "Elem 0 time value is %d\n", ExpectedTime );
bool bFail = false;
for( int i = 1 ; i < nBars ; i++ )
{
ExpectedTime += PeriodSecs;
int Diff = paRates[i].Time - ExpectedTime;
if( Diff )
{
fprintf( pLogFile, "Elem %d differed from expected time by %d periods and %d seconds\n", i, Diff / PeriodSecs, abs( Diff % PeriodSecs ) );
bFail = true;
}
ExpectedTime = paRates[i].Time;
}
fprintf( pLogFile, "The rate array %s time validation.\n\n", bFail ? "failed" : "passed" );
fclose( pLogFile );
}
Here's a sample of the output.. this one for EURUSD, charted on v.4.00 Build 210
of Interbank FX Trader:
Verifying 2048 1-minute bars...
Elem 0 time value is 1190886060
Elem 432 differed from expected time by 1 periods and 0 seconds
Elem 678 differed from expected time by 1 periods and 0 seconds
Elem 818 differed from expected time by 4 periods and 0 seconds
Elem 839 differed from expected time by 1 periods and 0 seconds
Elem 886 differed from expected time by 1 periods and 0 seconds
Elem 1026 differed from expected time by 1 periods and 0 seconds
Elem 1169 differed from expected time by 1 periods and 0 seconds
Elem 2021 differed from expected time by 1 periods and 0 seconds
The rate array failed time validation.
This one was fairly tame. I've also tried on vanilla MetaTrader 4.00 Build 210,
which reported thousands of errors (there was also much more data returned - over
60,000 bars).
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I've found that, at least when using ArrayCopyRates to send price data to a DLL, the time field in the rate info records does not always have the expected contents. In some cases, the times seem to skip one or more bars (in some cases hundreds or thousands). I've even encountered a situation where the most recent tick on a one-minute chart was supposedly about 77 days older than the tick before it! (That's how I found the issue - it was confusing the heck out of a DLL I'm writing.)
Here's a C++ function I wrote to test and verify this problem:
#pragma pack(push,1) struct MqlRateInfo { unsigned Time; double Open; double Low; double High; double Close; double Volume; }; #pragma pack(pop) CORE_EXP void CORE_API ValidateRateTimes( MqlRateInfo const *paRates, int nBars, int Period ) { int PeriodSecs = Period * 60; FILE *pLogFile = fopen( "C:\\temp\\MetaTrader Bug.log", "w+" ); if( !pLogFile ) return; fprintf( pLogFile, "Verifying %d %d-minute bars...\n", nBars, Period ); unsigned ExpectedTime = paRates->Time; fprintf( pLogFile, "Elem 0 time value is %d\n", ExpectedTime ); bool bFail = false; for( int i = 1 ; i < nBars ; i++ ) { ExpectedTime += PeriodSecs; int Diff = paRates[i].Time - ExpectedTime; if( Diff ) { fprintf( pLogFile, "Elem %d differed from expected time by %d periods and %d seconds\n", i, Diff / PeriodSecs, abs( Diff % PeriodSecs ) ); bFail = true; } ExpectedTime = paRates[i].Time; } fprintf( pLogFile, "The rate array %s time validation.\n\n", bFail ? "failed" : "passed" ); fclose( pLogFile ); }Here's a sample of the output.. this one for EURUSD, charted on v.4.00 Build 210 of Interbank FX Trader:
This one was fairly tame. I've also tried on vanilla MetaTrader 4.00 Build 210, which reported thousands of errors (there was also much more data returned - over 60,000 bars).
Is this a known issue? What's going on here??
Any insight will be greatly appreciated.
Cheers,
Kevin