Arrows of trades are shifted (has wrong time property) in backtest

 

I searched for this, but without success. Let's say that the search mechanism here is not as capable as Google :)

MetaTrader 4 build 625 (and 628 as well) in portable mode (and normal mode as well). Windows 8.1.


Here is the code, it's as simple as that:

void OnInit()
{
   int success = OrderSend(Symbol(), OP_BUY, 0.1, Ask, 0, 0, 0);
   return;

}

When I use this code I always got this: http://prntscr.com/38r7v1

The arrows of the trade has empty time property or something like that. No matter how many times I run the backtest, the arrow is always back in 1970.


Now, if I add the tick event handler and run the backtest again:

void OnInit()
{
   int success = OrderSend(Symbol(), OP_BUY, 0.1, Ask, 0, 0, 0);
   return;
}

void OnTick(){}

On the first backtest I still don't see the arrow: http://prntscr.com/38ragn

But on the next try the arrow is right where the previous backtest ended: http://prntscr.com/38rbq9

 

I'm a little confused what you're trying to do.

Do you realise that you are placing an order before the first tick has even been received?

You shouldn't be placing trades in OnInit.

The reason you see an arrow in 1970 is because 01 January 1970 is considered the beginning of time for MQL4.

 

Well, this behaviour is new for MT4, I was always using the Init event for quick tests without any problems. And this actually works on demo, in reality there is no need to wait for a tick in order to send a trade.

It works in OnTick(), so the problem seems to be in OnInit(). At least there is a trade created with all the right data, then who cares about those arrows :)))

Thanks by the way, at least I got the idea why that happens.

Reason: