LoadMoreHistory doesn't work when indicator used in Bot
Created at 06 Apr 2021, 06:58
LoadMoreHistory doesn't work when indicator used in Bot
06 Apr 2021, 06:58
Hi,
I have a multi-currency indicator that works fine as an indicator. It auto-loads history if there is not enough when you get the symbol bar data on initializing the indicator. If you scroll back the On Calculate will load more bar data as well. See the code below. However, when I place the indicator into a Bot, loadmorehistory does not return any bars. It also seems the backtesting engine starts the indicators at an earlier date than the date range you select through the interface. is this an error by design or what?
public override void Calculate(int index)
{
try
{
int p0 = -1;
if (index < 0 || TimeFrame >= TimeFrame.Daily) return;
//Load more currency bars when the instance symbol bars start before the other symbols
for (int i = 0; i < prdMS.Length; i++)
{
while (Bars.OpenTimes[index] < prdMS[i].OpenTimes[0])
{
var loadedCount = prdMS[i].LoadMoreHistory();
SeriesStartDates[i] = prdMS[i].OpenTimes[0];
if (loadedCount==0)
{
Print (prdMS[i].SymbolName+" failed to load more history.");
break;
}
else
{
Print("{0} Loaded {1} bars on {2} Timeframe. {3} total bars.", prdMS[i].SymbolName, loadedCount, TimeFrame, prdMS[i].Count);
}
}
}
PanagiotisCharalampous
06 Apr 2021, 08:51
Hi lec0456,
LoadMoreHistory does not work on backtesting at the moment.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous