Geting 200days or more of history data - negative index problem
Geting 200days or more of history data - negative index problem
30 Nov 2018, 22:17
Hi everyone,
I'm trying to determine the price range (max/min) of symbol over 200days or more back. I'm not interested in raw data but aggregated - SMA. I'm strugling to access such data far in history as the needed index ends up being negative numbers. I know the platform has the data as I can see those when writing indicator.
here is a code snippet to test it:
private void GetSmaInfoData(MarketSeries series, SimpleMovingAverage indicator, int smaValuesCount, DateTime barTime) { var data = new List<PriceInfo>(smaValuesCount); var barIndex = series.OpenTime.GetIndexByTime(barTime); for (int i = barIndex - smaValuesCount + 1; i <= barIndex; i++) { //indicator.Calculate(i); data.Add(new PriceInfo(series.OpenTime[i], indicator.Result[i])); } }
I looked up how is SMA indicator implemented and basically copied the code. However when on 1h timeframe and looking 200 days back (24*200=4800= smaValuesCount) the result of
OpenTime.GetIndexByTime(barTime);
is not high enough number to allow deducing 4800 and not getting below 0. Assume barTime to be LastClosed bar. When index is below zero, result time is obviously Datetime.Min and value is NaN. As you may guess I tried calling the Calculate method myself hoping it will force API to preload more data, but than I realized it would probably require it to reindex somehow.
Is there a way I can tell API to give me more headroom to acces data further in history? What is the limit when accessing data in IndicatorDataSeries, DataSeries and TimeSeries?
btw. I have noticed getting MarketSeries through MarketData.GetSeries() method gives me a bit more headroom, than MarketSeries of the cBot itself.
Replies
marek.kysely.84@gmail.com
01 Dec 2018, 10:35
Thanks Paul, but this is not what I'm looking for. I already have such data.
@marek.kysely.84@gmail.com
marek.kysely.84@gmail.com
01 Dec 2018, 10:44
( Updated at: 21 Dec 2023, 09:21 )
I really would like to know what is the logic behind the series data population. Did a small test. It made me think if I'm doing something unexpected.
As you can see, the last closed bar index is different for every symbol and so the ability to go back in history.
Is there anyone from cAlgo/cTrader team to explain it?
@marek.kysely.84@gmail.com
ClickAlgo
01 Dec 2018, 09:31
Hi Marek,
I do not know if this will help, but you can load historical data going back 15 years using the tool below, let me know if you want a free copy.
https://clickalgo.com/ctrader-historical-backtest-data-converter
Paul.
@ClickAlgo