BUG: Missing Tick (Volume=1) when running multiple versions of same expert

 
I have an expert which is running on four pairs. It does trading on new bars only by checking if (Volume[0]>1) return;

Occasionally (not consistently) it misses the first a tick for one pair and starts with Volume=2
(it may miss other ticks as well but with Volume=1 is were we notice).

See USDCHF below where the new tick starts with Volume=2.

The output lines which say "start()" are the very first command in the start() function, so there's no code in the expert that could bypass the first tick.

This is from build 186 but also happened in 185 (dunno about erlier versions).


Markus




...
13:59:26 JOSH-Expert USDJPY,H1: OnTick Bid= 118.05 Volume= 1220
13:59:26 JOSH-Expert USDJPY,H1: start(): Volume= 1221Bars= 530 TradeAllowed= 1
13:59:26 JOSH-Expert USDJPY,H1: OnTick Bid= 118.04 Volume= 1221
13:59:27 JOSH-Expert USDJPY,H1: start(): Volume= 1222Bars= 530 TradeAllowed= 1
13:59:27 JOSH-Expert USDJPY,H1: OnTick Bid= 118.03 Volume= 1222
13:59:28 JOSH-Expert USDJPY,H1: start(): Volume= 1225Bars= 530 TradeAllowed= 1
13:59:28 JOSH-Expert USDJPY,H1: OnTick Bid= 118.03 Volume= 1225
13:59:29 JOSH-Expert USDJPY,H1: start(): Volume= 1226Bars= 530 TradeAllowed= 1
13:59:29 JOSH-Expert USDJPY,H1: OnTick Bid= 118.04 Volume= 1226
13:59:29 JOSH-Expert EURUSD,H1: start(): Volume= 1434Bars= 530 TradeAllowed= 1
13:59:29 JOSH-Expert EURUSD,H1: OnTick Bid= 1.1703 Volume= 1434
13:59:29 JOSH-Expert USDCHF,H1: start(): Volume= 1453Bars= 530 TradeAllowed= 1
13:59:29 JOSH-Expert USDCHF,H1: OnTick Bid= 1.3143 Volume= 1453

13:59:29 JOSH-Expert USDJPY,H1: start(): Volume= 1227Bars= 530 TradeAllowed= 1
13:59:29 JOSH-Expert USDJPY,H1: OnTick Bid= 118.03 Volume= 1227
13:59:30 JOSH-Expert USDJPY,H1: start(): Volume= 1228Bars= 530 TradeAllowed= 1
13:59:30 JOSH-Expert USDJPY,H1: OnTick Bid= 118.04 Volume= 1228
13:59:30 JOSH-Expert USDJPY,H1: start(): Volume= 1229Bars= 530 TradeAllowed= 1
13:59:30 JOSH-Expert USDJPY,H1: OnTick Bid= 118.03 Volume= 1229
13:59:35 JOSH-Expert USDJPY,H1: start(): Volume= 1230Bars= 530 TradeAllowed= 1
13:59:35 JOSH-Expert USDJPY,H1: OnTick Bid= 118.04 Volume= 1230
13:59:36 JOSH-Expert GBPUSD,H1: start(): Volume= 1915Bars= 530 TradeAllowed= 1
13:59:36 JOSH-Expert GBPUSD,H1: OnTick Bid= 1.7379 Volume= 1915
13:59:36 JOSH-Expert USDJPY,H1: start(): Volume= 1231Bars= 530 TradeAllowed= 1
13:59:36 JOSH-Expert USDJPY,H1: OnTick Bid= 118.05 Volume= 1231
13:59:36 JOSH-Expert EURUSD,H1: start(): Volume= 1435Bars= 530 TradeAllowed= 1
13:59:36 JOSH-Expert EURUSD,H1: OnTick Bid= 1.1702 Volume= 1435
13:59:40 JOSH-Expert USDJPY,H1: start(): Volume= 1232Bars= 530 TradeAllowed= 1
13:59:40 JOSH-Expert USDJPY,H1: OnTick Bid= 118.03 Volume= 1232
13:59:40 JOSH-Expert USDJPY,H1: start(): Volume= 1233Bars= 530 TradeAllowed= 1
13:59:40 JOSH-Expert USDJPY,H1: OnTick Bid= 118.02 Volume= 1233
13:59:41 JOSH-Expert USDJPY,H1: start(): Volume= 1234Bars= 530 TradeAllowed= 1
13:59:41 JOSH-Expert USDJPY,H1: OnTick Bid= 118.03 Volume= 1234
13:59:41 JOSH-Expert USDJPY,H1: start(): Volume= 1235Bars= 530 TradeAllowed= 1
13:59:41 JOSH-Expert USDJPY,H1: OnTick Bid= 118.05 Volume= 1235
13:59:42 JOSH-Expert USDJPY,H1: start(): Volume= 1236Bars= 530 TradeAllowed= 1
13:59:42 JOSH-Expert USDJPY,H1: OnTick Bid= 118.03 Volume= 1236
13:59:45 JOSH-Expert GBPUSD,H1: start(): Volume= 1916Bars= 530 TradeAllowed= 1
13:59:45 JOSH-Expert GBPUSD,H1: OnTick Bid= 1.738 Volume= 1916
13:59:45 JOSH-Expert USDJPY,H1: start(): Volume= 1237Bars= 530 TradeAllowed= 1
13:59:45 JOSH-Expert USDJPY,H1: OnTick Bid= 118.04 Volume= 1237
13:59:47 JOSH-Expert GBPUSD,H1: start(): Volume= 1917Bars= 530 TradeAllowed= 1
13:59:47 JOSH-Expert GBPUSD,H1: OnTick Bid= 1.7381 Volume= 1917
13:59:47 JOSH-Expert USDJPY,H1: start(): Volume= 1238Bars= 530 TradeAllowed= 1
13:59:47 JOSH-Expert USDJPY,H1: OnTick Bid= 118.03 Volume= 1238
13:59:48 JOSH-Expert GBPUSD,H1: start(): Volume= 1918Bars= 530 TradeAllowed= 1
13:59:48 JOSH-Expert GBPUSD,H1: OnTick Bid= 1.7379 Volume= 1918
13:59:48 JOSH-Expert GBPUSD,H1: start(): Volume= 1Bars= 531 TradeAllowed= 1
13:59:48 JOSH-Expert GBPUSD,H1: OnTick Bid= 1.738 Volume= 1
13:59:48 JOSH-Expert GBPUSD,H1: Signal base : gAscState= -1, gTrendConfirm= 1, entrypoint= 0, exitpoint= 0
13:59:48 JOSH-Expert GBPUSD,H1: Signal summary: buy(close)= 0(1) --- sell(close)= 1 (0)
13:59:48 JOSH-Expert GBPUSD,H1: Signal Stops: Short/Long 1.7408 0
13:59:48 JOSH-Expert GBPUSD,H1:
13:59:48 JOSH-Expert GBPUSD,H1: Stops: Short/Long 1.7408 0
13:59:50 JOSH-Expert USDJPY,H1: start(): Volume= 1Bars= 531 TradeAllowed= 1
13:59:50 JOSH-Expert USDJPY,H1: OnTick Bid= 118.04 Volume= 1
13:59:50 JOSH-Expert USDJPY,H1: Signal base : gAscState= 0, gTrendConfirm= 0, entrypoint= 0, exitpoint= 0
13:59:50 JOSH-Expert USDJPY,H1: Signal summary: buy(close)= 0(0) --- sell(close)= 0 (0)
13:59:50 JOSH-Expert USDJPY,H1: Signal Stops: Short/Long 0 117.9333
13:59:50 JOSH-Expert USDJPY,H1:
13:59:59 JOSH-Expert GBPUSD,H1: start(): Volume= 2Bars= 531 TradeAllowed= 1
13:59:59 JOSH-Expert GBPUSD,H1: OnTick Bid= 1.7382 Volume= 2
13:59:59 JOSH-Expert EURUSD,H1: start(): Volume= 1Bars= 531 TradeAllowed= 1
13:59:59 JOSH-Expert EURUSD,H1: OnTick Bid= 1.1701 Volume= 1
13:59:59 JOSH-Expert EURUSD,H1: Signal base : gAscState= -1, gTrendConfirm= 1, entrypoint= 0, exitpoint= 0
13:59:59 JOSH-Expert EURUSD,H1: Signal summary: buy(close)= 0(1) --- sell(close)= 1 (0)
13:59:59 JOSH-Expert EURUSD,H1: Signal Stops: Short/Long 1.1713 0
13:59:59 JOSH-Expert EURUSD,H1:
13:59:59 JOSH-Expert EURUSD,H1: Stops: Short/Long 1.1713 0
13:59:59 JOSH-Expert USDCHF,H1: start(): Volume= 2Bars= 531 TradeAllowed= 1
13:59:59 JOSH-Expert USDCHF,H1: OnTick Bid= 1.3142 Volume= 2

14:00:01 JOSH-Expert EURUSD,H1: start(): Volume= 2Bars= 531 TradeAllowed= 1
14:00:01 JOSH-Expert EURUSD,H1: OnTick Bid= 1.17 Volume= 2
14:00:01 JOSH-Expert GBPUSD,H1: start(): Volume= 3Bars= 531 TradeAllowed= 1
14:00:01 JOSH-Expert GBPUSD,H1: OnTick Bid= 1.7379 Volume= 3
14:00:02 JOSH-Expert USDJPY,H1: start(): Volume= 2Bars= 531 TradeAllowed= 1
14:00:02 JOSH-Expert USDJPY,H1: OnTick Bid= 118.03 Volume= 2
14:00:02 JOSH-Expert USDCHF,H1: start(): Volume= 3Bars= 531 TradeAllowed= 1
14:00:02 JOSH-Expert USDCHF,H1: OnTick Bid= 1.3145 Volume= 3
14:00:03 JOSH-Expert USDCHF,H1: start(): Volume= 4Bars= 531 TradeAllowed= 1
14:00:03 JOSH-Expert USDCHF,H1: OnTick Bid= 1.3144 Volume= 4
14:00:03 JOSH-Expert USDJPY,H1: start(): Volume= 3Bars= 531 TradeAllowed= 1
14:00:03 JOSH-Expert USDJPY,H1: OnTick Bid= 118.04 Volume= 3
14:00:03 JOSH-Expert EURUSD,H1: start(): Volume= 3Bars= 531 TradeAllowed= 1
14:00:03 JOSH-Expert EURUSD,H1: OnTick Bid= 1.1701 Volume= 3

14:00:04 JOSH-Expert USDJPY,H1: start(): Volume= 4Bars= 531 TradeAllowed= 1
14:00:04 JOSH-Expert USDJPY,H1: OnTick Bid= 118.03 Volume= 4
14:00:05 JOSH-Expert EURUSD,H1: start(): Volume= 4Bars= 531 TradeAllowed= 1
14:00:05 JOSH-Expert EURUSD,H1: OnTick Bid= 1.17 Volume= 4
14:00:05 JOSH-Expert GBPUSD,H1: start(): Volume= 4Bars= 531 TradeAllowed= 1
14:00:05 JOSH-Expert GBPUSD,H1: OnTick Bid= 1.738 Volume= 4
14:00:06 JOSH-Expert GBPUSD,H1: start(): Volume= 5Bars= 531 TradeAllowed= 1
14:00:06 JOSH-Expert GBPUSD,H1: OnTick Bid= 1.7379 Volume= 5
14:00:06 JOSH-Expert USDJPY,H1: start(): Volume= 5Bars= 531 TradeAllowed= 1
14:00:06 JOSH-Expert USDJPY,H1: OnTick Bid= 118.04 Volume= 5
14:00:06 JOSH-Expert USDCHF,H1: start(): Volume= 5Bars= 531 TradeAllowed= 1
14:00:06 JOSH-Expert USDCHF,H1: OnTick Bid= 1.3143 Volume= 5
14:00:06 JOSH-Expert USDJPY,H1: start(): Volume= 6Bars= 531 TradeAllowed= 1
14:00:06 JOSH-Expert USDJPY,H1: OnTick Bid= 118.03 Volume= 6
14:00:06 JOSH-Expert EURUSD,H1: start(): Volume= 5Bars= 531 TradeAllowed= 1
14:00:06 JOSH-Expert EURUSD,H1: OnTick Bid= 1.1701 Volume= 5
14:00:07 JOSH-Expert USDCHF,H1: start(): Volume= 6Bars= 531 TradeAllowed= 1
14:00:07 JOSH-Expert USDCHF,H1: OnTick Bid= 1.3144 Volume= 6
14:00:11 JOSH-Expert USDJPY,H1: start(): Volume= 7Bars= 531 TradeAllowed= 1
14:00:11 JOSH-Expert USDJPY,H1: OnTick Bid= 118.06 Volume= 7
14:00:11 JOSH-Expert EURUSD,H1: start(): Volume= 6Bars= 531 TradeAllowed= 1
14:00:11 JOSH-Expert EURUSD,H1: OnTick Bid= 1.1703 Volume= 6
14:00:11 JOSH-Expert EURUSD,H1: start(): Volume= 7Bars= 531 TradeAllowed= 1
14:00:11 JOSH-Expert EURUSD,H1: OnTick Bid= 1.17 Volume= 7
14:00:18 JOSH-Expert GBPUSD,H1: start(): Volume= 6Bars= 531 TradeAllowed= 1
14:00:18 JOSH-Expert GBPUSD,H1: OnTick Bid= 1.7382 Volume= 6
14:00:18 JOSH-Expert USDJPY,H1: start(): Volume= 9Bars= 531 TradeAllowed= 1
14:00:18 JOSH-Expert USDJPY,H1: OnTick Bid= 118.05 Volume= 9
14:00:18 JOSH-Expert EURUSD,H1: start(): Volume= 8Bars= 531 TradeAllowed= 1
14:00:18 JOSH-Expert EURUSD,H1: OnTick Bid= 1.1702 Volume= 8
14:00:18 JOSH-Expert USDJPY,H1: start(): Volume= 12Bars= 531 TradeAllowed= 1
14:00:18 JOSH-Expert USDJPY,H1: OnTick Bid= 118.04 Volume= 12
14:00:18 JOSH-Expert EURUSD,H1: start(): Volume= 9Bars= 531 TradeAllowed= 1
14:00:18 JOSH-Expert EURUSD,H1: OnTick Bid= 1.1701 Volume= 9
14:00:18 JOSH-Expert GBPUSD,H1: start(): Volume= 7Bars= 531 TradeAllowed= 1
14:00:18 JOSH-Expert GBPUSD,H1: OnTick Bid= 1.7378 Volume= 7
14:00:18 JOSH-Expert USDJPY,H1: start(): Volume= 13Bars= 531 TradeAllowed= 1
14:00:18 JOSH-Expert USDJPY,H1: OnTick Bid= 118.05 Volume= 13
14:00:19 JOSH-Expert USDCHF,H1: start(): Volume= 7Bars= 531 TradeAllowed= 1
 

Occasionally (not consistently) it misses the first a tick for one pair and starts with Volume=2
(it may miss other ticks as well but with Volume=1 is were we notice).

The documentation says that ticks can be ignored at some condition:

By new quotations "start()" function of attached expert advisors and custom indicator programs is executed. If by new quotations "start()" function, triggered on the previous quotation, was fulfilled, the next calling "start()" function will be executed only after "return()" instruction. All new quotations that receiving during program execution, are ignored by program.

Metaquotes server has switched to high freq datafeed recently. That may cause the condition above happening at the first tick randomly.
 
A more reliable method of checking for new bar is the following:

 static datetime bartime = 0;
 if (bartime == Time[0])
  return 0;
 bartime = Time[0];