Array out of range in strategy tester

 

Can anybody think how

datetime bar_time=Time[1];

can cause an array out of range critical error while backtesting?

It is a client doing the backtesting and apparently the history has been downloaded from elsewhere than the platform broker.

I thought that if data is missing, there is a mismatch reported and that bar is skipped.

 
Is this line of code in the OnInit() ?
 
drazen64:
Is this line of code in the OnInit() ?
No, it's in a function that is only called from within OnTick
 
GumRai:

Can anybody think how

can cause an array out of range critical error while backtesting?

It is a client doing the backtesting and apparently the history has been downloaded from elsewhere than the platform broker.

I thought that if data is missing, there is a mismatch reported and that bar is skipped.

Probably this bar[1] does not exist at the beginning of your testing.
Depends first bar of the tester-history and the beginning time of your testing
 
gooly:
Probably this bar[1] does not exist at the beginning of your testing.
Depends first bar of the tester-history and the beginning time of your testing
Yes, but I thought that if data is missing, there is a mismatch reported and that bar is skipped.
 
GumRai:

Can anybody think how

can cause an array out of range critical error while backtesting?

It is a client doing the backtesting and apparently the history has been downloaded from elsewhere than the platform broker.

I thought that if data is missing, there is a mismatch reported and that bar is skipped.

Always check the "Bars" variable to make sure the index into Time[], High[], Low[], Close[], etc. will be valid or not.

This is especially important when running under the Strategy Tester with no "Use Date" limits, and during the first bar.

There will be no "mismatch" reported, because there is no mismatch. It simply just has the current bar data available.

 
Missing Time[1] can happen, if you use some 3rd party fxt generator. While the MT4 built-in fxt generator creates decent amount (I think 1000) static candles before the test runs, there may be none in the 3rd party file if the coder did not implement it.
 

Thanks,

I will check the value for Bars and see how it works out.

 
GumRai:

Thanks,

I will check the value for Bars and see how it works out.

Start visual trading in the tester then you'll see the first bar...
 
gooly:
Start visual trading in the tester then you'll see the first bar...
I've never had a problem. I don't download data, I just use the broker's.
 

;) there is always a first time ;)

Reason: