Bug with build 216?

 
Hi MetaQuotes,

I've been developing an Expert recently which uses other currency pairs to make it's decisions, using commands like "iMA(symbol, timeFrame, period, 0, maType, appliedPrice, 1)" and "iTime(symbol, timeFrame, 1);" etc.

After completing an Expert and running it using your strategy tester, all looked good. However, when I then ran it live, I discovered that the taken trades vary quite substantially to the trades produced by your simulator.

After coming close to tearing my hair out over this (not that I have a lot left) I discovered that the problem actually lies with MetaTrader and the way quotes are registered in real time.

Like most people, the quote or signal information I use is that of the previous bar, as the commands I mentioned above show. However, when the markets are relatively quiet, quotes for a specific currency pair may not come in for quite some time. If during this time, a new bar should have been started but wasn't (because a new quote hadn't come in), executing a command like "iMA(symbol, timeFrame, period, 0, maType, appliedPrice, 1)" will actually produce the MA of what should now be bar 2.

I've managed to get around this problem with the following code:

datetime tradingChartTime = iTime(NULL, 0, 1);
datetime signalChartTime = iTime(symbol, timeFrame, 1);
if (signalChartTime != tradingChartTime)
{
Print("Signal chart: " + splitArray[1] + " time: " + TimeToStr(signalChartTime, TIME_DATE|TIME_MINUTES) +
" does not correspond with trading chart: " + getChartDetails(2) + " time: " + TimeToStr(tradingChartTime, TIME_DATE|TIME_MINUTES) + "!!");

return (0);
}

Basically, this code compares the time of Bar[1] on the chart being traded with the time of Bar[1] on the charts used to generate the buy/sell signals. If the times don't match (i.e. a new bar has been started on the chart being traded but has not yet been started on one or more of the charts being used to generate the signals because a quote hasn't been received for that chart), no signal is generated.

As soon as I included this code, my live trades pretty much matched my simulated trades. There remains one problem however. When a new bar is started on the trading chart, it can sometimes take up to 20 minutes (!) for that same bar to be started on one of the charts used to generate the signals, if that particular currency pair is quiet. By this time, the price I'm able to get when trading in real time is often quite different to the price I'm able to get when carrying out a simulation....
 
No tick, no bar.
Who is your Dealer?
 
What do you mean by "No tick, no bar"? Surely if a price stays stationary during a bar's time period, that bar should be recorded as a stripe (i.e. OHLC all being the same price)?

Also regarding your dealer question, this problem occurs regardless of the dealer used.
 
If there is no tick received during the "time" of a bar, there will be no bar.
Study 1 minute chart during slow period, you will find holes. Hole = missing bar, but no visible "hole" in the chart. Just the time pattern :01 :02 :04 :05 :07 gives the clue.
For discussion search "free of holes" chart.
Who is your dealer. Some tick faster than others.
 
Ah, I see what you're saying... So unless a quote is received, no bar is created.... mmm... that makes life interesting... Looks like I've got a bit more coding to do!

Cheers for your help! Oh, and I'm currently testing my Experts on an Alpari demo account.
Reason: