Backtesting crashes for H4 server data
Backtesting crashes for H4 server data
01 Mar 2020, 17:30
Hi Panagiotis,
In early January I posted this bug in another thread, but it has not yet been fixed. The original thread was for a bug that was related to this and partly fixed, so this one perhaps fell through the cracks.
If I run a multicurrency bot over many pairs, then it crashes if I try to use "h4 bars from server (open prices)" for the backtesting data source. I can use other time frames (m1, h1, etc), but it consistently crashes with h4 data, with error: cBot crashed: Cache file `` is damaged and has been removed. It will be updated on next run. If the error persists, try clearing target symbol cache manually. Note, I don't mean running the bot on an H4 timeframe, that works. What is broken is if the timeframe is set to h4 and the backtesting settings use h4 open candles as a data source.
I have tried clearing the symbol cache, but that does not resolve the issue. This happens for Pepperstone and cTrader Beta builds in 3.7 (the same code worked fine in 3.6).
Here is a minimal sample that crashes in backtesting over a 1 year period (01/01/2019 - 01/01/2020). It runs for a short while on h4 candles before it crashes. It completes using m1 candles.
using System;
using System.Linq;
using System.Collections.Generic;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class Test : Robot
{
string[] symbols =
{
"AUDCAD",
"AUDCHF",
"AUDJPY",
"AUDNZD",
"AUDUSD",
"CADCHF",
"CADJPY",
"CHFJPY",
"EURAUD",
"EURCAD",
"EURCHF",
"EURGBP",
"EURJPY",
"EURNZD",
"EURUSD",
"GBPAUD",
"GBPCAD",
"GBPCHF",
"GBPJPY",
"GBPNZD",
"GBPUSD",
"NZDCAD",
"NZDCHF",
"USDJPY",
"NZDJPY",
"NZDUSD",
"USDCHF",
"USDCAD"
};
List< Strategy > strategies = new List< Strategy >();
protected override void OnStart()
{
foreach ( var sym in symbols )
{
var s = new Strategy();
s.init( this, sym );
strategies.Add( s );
}
}
}
public class Strategy
{
RelativeStrengthIndex rsi;
Robot bot;
string symbol;
public void init( Robot bot, string symbol )
{
this.symbol = symbol;
this.bot = bot;
Bars bars = bot.MarketData.GetBars( bot.TimeFrame, symbol );
rsi = bot.Indicators.RelativeStrengthIndex( bars.ClosePrices, 14 );
bars.BarOpened += OnBarOpened;
}
void OnBarOpened(BarOpenedEventArgs obj)
{
if ( rsi.Result.Last(1) > 70 && rsi.Result.Last(2) <= 70 )
{
bot.ExecuteMarketOrder( TradeType.Sell, symbol, 10000, symbol, 10.0, 10.0 );
}
}
}
}
Replies
mpistorius
12 Mar 2020, 17:52
RE: Backtesting crashes for H4 server data
PanagiotisCharalampous said:
Hi mpistorius,
We will check this and come back to you.
Best Regards,
Panagiotis
Hi Panagiotis,
Any news on this? Were you able to reproduce the problem? Is there a workaround, other than running on m1 server data? That makes optimization impossibly slow.
Thanks
@mpistorius
PanagiotisCharalampous
13 Mar 2020, 08:33
Hi mpistorius,
We managed to reproduce it and we are working on a fix. Unfortunately there is no workaround at the moment.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
03 Mar 2020, 11:43
Hi mpistorius,
We will check this and come back to you.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous