Array out of Range because not enough bars in the backtesting

Back to topics list To post a new topic, please log in or register
avatar
83
BeLikeWater 2015.03.04 12:19
 

Hello Im programming an EA that analizes the 300 bars prior to the current bar. So If I try to backtest in the begginning of my data I get the "array out of range" because the bars.


How I should handle this one? I mean I want the code to analize if there is enough bars to run the EA in the backtest (300> in this case more or less)


Could anybody help?


Thank you

avatar
2017
gooly 2015.03.04 12:36 #
 

A solution depends on your code.

If you post it please use SRC-button

avatar
83
BeLikeWater 2015.03.04 12:42 #
 

My code reads the x number of bars with the same time for y days.

Meaning it reads the values of the 17:00 H1 bar of the priors 10 days. As you can image at the beggining there are not 10 days to read, so then its when it gives the array out of range error.

avatar
2017
gooly 2015.03.04 13:38 #
 

1) Did you check the size of the array?

2) Did you check the no. of available bars?

avatar
83
BeLikeWater 2015.03.04 13:43 #
 
Gooly nop I didnt. I only program EA´s but I have remember now that when trying to code indicators, there were functions for that!
avatar
10
barando 2015.03.04 18:55 #
 
if(Bars >300){

calculation 

}
avatar
83
BeLikeWater 2015.03.05 13:38 #
 
Yeah Barando. Thank you. My brain working slow these days. But thanks you two.
Back to topics list  

To add comments, please log in or register