Get NAN when visual backtesting
Get NAN when visual backtesting
28 Aug 2019, 09:23
I want get OHLC value that does not show in graph like 500 bars before(when backtesting).
method 1
(time2 is time frame in this code I select 1hour tf)
var time2 = MarketData.GetSeries(time2);
Print("HIGH " + time2 .High.Last(200));
It print out NAN value when I backtesting.
method 2 still the same.
int index2 = time2 .OpenTime.GetIndexByTime(Server.Time.AddHours(-200));
Print("LAST " + time2 .High[index2]);
2.I have question What is different between method 1 and method2
my purpose is get OHLC data while visual backtesting.
Thanks
Chanapong
Replies
chanapong3
28 Aug 2019, 10:14
This method is count bars in weekend ?
var time2 = MarketData.GetSeries(time2);
Print("HIGH " + time2 .High.Last(200));
You mean this method
int index2 = time2 .OpenTime.GetIndexByTime(Server.Time.AddHours(-200));
Print("LAST " + time2 .High[index2]);
is weekend not considered right ?
And Do you have any way to load more data before backtesting time ?
Because in forward test it is work normally.
Thanks for fast reply
@chanapong3
PanagiotisCharalampous
28 Aug 2019, 10:21
Hi chanapong3,
This method is count bars in weekend ?
var time2 = MarketData.GetSeries(time2);Print("HIGH " + time2 .High.Last(200));
You mean this methodint index2 = time2 .OpenTime.GetIndexByTime(Server.Time.AddHours(-200));
Print("LAST " + time2 .High[index2]);is weekend not considered right ?
Yest this is correct
And Do you have any way to load more data before backtesting time ?
Because in forward test it is work normally.
No but a workaround would be to start your backtesting earlier and set a condition in the cBot to start executing as soon as the required amount of data becomes available.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
28 Aug 2019, 10:08
Hi chanapong3,
The reason you get NaN is that cTrader does not load so many bars before backtesting start time.
The difference between the two methods is that going back 200 hours is not equivalent to going back 200 bars since using method 2 weekend gaps are not considered.
Best Regards,
Panagiotis
@PanagiotisCharalampous