Download MetaTrader 5

Array out of range in strategy tester

To add comments, please log in or register
Keith Watford
Moderator
9980
Keith Watford  

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.

Drazen Penic
2593
Drazen Penic  
Is this line of code in the OnInit() ?
Keith Watford
Moderator
9980
Keith Watford  
drazen64:
Is this line of code in the OnInit() ?
No, it's in a function that is only called from within OnTick
Carl Schreiber
6781
Carl Schreiber  
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
Keith Watford
Moderator
9980
Keith Watford  
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.
Fernando Carreiro
2241
Fernando Carreiro  
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.

Ex Ovo Omnia
3221
Ex Ovo Omnia  
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.
Keith Watford
Moderator
9980
Keith Watford  

Thanks,

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

Carl Schreiber
6781
Carl Schreiber  
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...
Keith Watford
Moderator
9980
Keith Watford  
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.
Carl Schreiber
6781
Carl Schreiber  

;) there is always a first time ;)

12
To add comments, please log in or register