Skew between tick time and current bar

 

Hi all,


I'm pretty new to MT4 and MQL, but I found a strange behavior on the following code:


void OnTick() {

  int order_action_status;

  MqlTick last_tick;

  SymbolInfoTick(Symbol(),last_tick);

  Print("TICK: " + TimeToString(last_tick.time, TIME_DATE|TIME_SECONDS));

}


That code produces an output like this:

2015.10.05 02:00:25.491    PAPERONE_WR_DIVERGENCE EURUSD,M1: TICK: 2015.10.05 01:00:24
2015.10.05 02:00:25.335    PAPERONE_WR_DIVERGENCE EURUSD,M1: TICK: 2015.10.05 01:00:24
2015.10.05 02:00:24.680    PAPERONE_WR_DIVERGENCE EURUSD,M1: TICK: 2015.10.05 01:00:23
2015.10.05 02:00:24.555    PAPERONE_WR_DIVERGENCE EURUSD,M1: TICK: 2015.10.05 01:00:23
2015.10.05 02:00:24.321    PAPERONE_WR_DIVERGENCE EURUSD,M1: TICK: 2015.10.05 01:00:23
2015.10.05 02:00:20.546    PAPERONE_WR_DIVERGENCE EURUSD,M1: TICK: 2015.10.05 01:00:19

2015.10.05 02:00:18.471    PAPERONE_WR_DIVERGENCE EURUSD,M1: TICK: 2015.10.05 01:00:17


The problem is that looking at the chart I can see the candle at 00:59:00 is still forming...using ticks in the future to create that candle....

What am I missing?


Regards,

Alberto

 

Are you testing in Visual mode? Then no problem. 

 
jollydragon:

Are you testing in Visual mode? Then no problem. 


Hi,


thank you for the quick reply, but I didn't understand it.

I'm not back-testing, the EA is attached to a real-time graph with 1minute candles; what I see is that when onTick() fires for a tick who has a time HH:MM:SS, inside the chart the candle under construction is that who has time HH:MM-2:SS

To reproduce the suspected issue it's enough to create an empty EA who has insidere the OnTick() function the following 3 lines:

MqlTick last_tick;

SymbolInfoTick(Symbol(),last_tick);

Print("TICK: " + TimeToString(last_tick.time, TIME_DATE|TIME_SECONDS));


If you attach the EA tho a graph, I'll see that the tick received and printed by the EA have a timestamp which is outside the range, related to the current candle.

For example, if in the graph the candle at 01:00 is under construction, I expect the bigger timestap of a tick should be 01:00:59 (but I see ticks with timestamp 01:01:XX)

I don't understand how it's possible


Thank you.

Regards,

Alberto

 

It sounds weird, and I never noticed anything like that. Can't that be just you did not focus properly the last bar? Switch the last bar data in your Data Panel (ctrl + d).

Sometimes (but rarely) the ticks swap (i.e. the next tick has older timestamp), but it is always within one second interval.

 
Ovo:

It sounds weird, and I never noticed anything like that. Can't that be just you did not focus properly the last bar? Switch the last bar data in your Data Panel (ctrl + d).

Sometimes (but rarely) the ticks swap (i.e. the next tick has older timestamp), but it is always within one second interval.


Hi all, please see below a screenshot to best explain what I meant; as you can see the candle at 16:41:00 is still under construction but I'm currenlty receiving thicks with timestamp 16:42:XX

It could be very useful if someone could try to run this test in his mt4 platform.

Regards,

Alberto


 
thriller: The problem is that looking at the chart I can see the candle at 00:59:00 is still forming...using ticks in the future to create that candle....
Telling us what you see isn't helpful as wed can't see it. Print your last_tick time, Time[0], and TimeCurrent() in one line so you can see all of them.
 
thriller:


Hi all, please see below a screenshot to best explain what I meant; as you can see the candle at 16:41:00 is still under construction but I'm currenlty receiving thicks with timestamp 16:42:XX

It could be very useful if someone could try to run this test in his mt4 platform.

Regards,

Alberto


What I can see in your picture is a candle at 16:43 under construction and your output reads 16:43 as well.