Bot stopps when TimeTillClose()
Created at 30 Nov 2020, 13:35
Bot stopps when TimeTillClose()
30 Nov 2020, 13:35
Hello,
my bot stopps sometimes when backtesting. I could figure out that it has something to do with TimeTillClose().
Symbol: USPJPY, m1
Error: "Crashed in OnTick with InvalidOperationException: Die Sequenz enthält keine Elemente." - "Bot was stopped"
Some Stopping Dates: 11 Feb 2011, 29 Apr 2011, 14 Nov 2014, 16 Mar 2018 (always a Friday)
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.EasternStandardTime, AccessRights = AccessRights.None)]
public class NewcBot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
protected override void OnStart()
{
// Put your initialization logic here
}
protected override void OnTick()
{
// Put your core logic here
var list = Symbol.MarketHours.Sessions;
if (Time.TimeOfDay == TimeSpan.FromMinutes(1019))
{
TimeSpan tim = new TimeSpan();
tim = Symbol.MarketHours.TimeTillClose();
}
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
PanagiotisCharalampous
30 Nov 2020, 16:09
Hi Schaitan,
I could not reproduce the reported issue. Please let us know your broker, the symbol and the data sources (ticks, m1 bars etc)
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous