aborted by timeout
aborted by timeout
29 Sep 2022, 07:29
Hello
I've attached a simple indicator which loads bars until a specific date. This indicator will throw the following error on .net 6 once places on charts with a lot of data such as 10-range SpotCrude (and will not necessary will happen on charts with a little data such as 10-range EURGBP):
29/09/2022 07:28:16.955 | Indicator instance [LoadBarsTestInd, SpotCrude, Ra10] aborted by timeout.
Thanks
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo
{
[Indicator(AccessRights = AccessRights.FullAccess)]
public class LoadBarsTestInd : Indicator
{
[Parameter(DefaultValue = "Hello world!")]
public string Message { get; set; }
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
protected override void Initialize()
{
DateTime dateTime = new DateTime(2022, 1, 1);
Print("start " + Bars.OpenTimes[0]);
LoadBars(dateTime);
Print("finish" + Bars.OpenTimes[0]);
}
public override void Calculate(int index)
{
// Calculate value at specified index
// Result[index] =
}
public bool LoadBars(DateTime requiredStartDate)
{
//AppendLogLog("LoadBars");
//Print("LoadBars");
bool result = false;
while (Bars.OpenTimes[0] > requiredStartDate)
{
result = true;
//AppendLogLog("Bars.OpenTimes[0]= " + Bars.OpenTimes[0]);
//Print("Bars.OpenTimes[0]= " + Bars.OpenTimes[0]);
int loadedCount = Bars.LoadMoreHistory();
//AppendLogLog("loadedCount= " + loadedCount);
//Print("loadedCount= " + loadedCount);
if (loadedCount == 0)
break;
}
return (result);
}
}
}
Replies
PanagiotisChar
04 Oct 2022, 17:15
Hi yuval,
Check Go to Date indicator to see how this is handled there.
Need Help? Join us on Telegram
@PanagiotisChar
eynt
05 Oct 2022, 20:19
RE:
Thank you
This indicator does load data without throwing errors, I will try to use this approach on my projects.
However, if I have several other indicators on my charts, each time GoToData get more data (which can be dozens of times if the date is far in the past) all the indicators are being reloaded again and again which can slows down the entire process of presenting the chart.
Is there a way to make other indicators load themselves only once - when the GoToData finishes getting data?
@eynt
PanagiotisCharalampous
29 Sep 2022, 11:12
Hi yuval,
This is the normal behavior. Whenever new bars are loaded the indicator is reinitialized and the previous instance is aborted. You will see this message until all data is loaded.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous