Backtester Index is out of range Error

All posts which do not fit into any other sections of the forum.

Moderator: admin

Backtester Index is out of range Error

Postby jch001 » Wed Jun 15, 2016 2:18 pm

Hi,

two questions. firstly I know I am probably missing something obvious here. I want to read in the current day candle at a set time in the morning, I have put the code in a strategy rather than the indicator as it was only a few lines. However, after about 3 months of back testing (this is the same even if I change the dates) suddenly I get an "out of range Error" when reading in the high.

1) am I missing something that is causing the error? its like the memory is being filled or something.

Code: Select all
    local daycandle = loadcandle(daycandle, selectedtime, "D1")   
    local i = core.findDate(daycandle, selectedtime, false);
    if i == -1 then             
          return
    end
    top = daycandle.high[i];
    bottom = daycandle.low[i];

-- fyi loadcandle from the proc
candles = host:execute("getHistory", 1, source:instrument(), "D1", math.floor(selectedtime), selectedtime, source:isBid());


2) finally when I run this in the Debugger the day candle returned is not the open day candle, for the time specified. but, the complete candle for the day. is there a better way of doing this to get the open candle at the time specified?

thanks
jch001
 
Posts: 14
Joined: Tue Aug 28, 2012 3:41 am

Re: Backtester Index is out of range Error

Postby Julia CJ » Thu Jun 16, 2016 6:50 am

Hi Jch001,

1)
am I missing something that is causing the error? its like the memory is being filled or something.


You have the notification “out of range Error”, because the bar at the check moment is not specified. Please explain for which event you check it.

2)
finally when I run this in the Debugger the day candle returned is not the open day candle, for the time specified. but, the complete candle for the day. is there a better way of doing this to get the open candle at the time specified?

Apparently, the base reason is in this stream:
candles = host:execute("getHistory", 1, source:instrument(), "D1", math.floor(selectedtime), selectedtime, source:isBid());
Timeframe is D1, i.e. D1 is the day bars. Therefore you have the bars of all day. Please select the needed timeframe as a result you will have the bars of other time interval.
Julia CJ
 


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 20 guests