Missing bars in MarketData.GetSeries()

Created at 30 Mar 2019, 20:10
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
VI

VitoCz

Joined 30.01.2019

Missing bars in MarketData.GetSeries()
30 Mar 2019, 20:10


I have found a possible bug in the implementation of MarketData.GetSeries() method which returns series with missing most recent bar(s).
Here is a very simple indicator I created to illustrate the problem:

using System;
using cAlgo.API;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class LastBars : Indicator
    {
        protected override void Initialize()
        {
            Print("Monthly TF, Last OpenTime = {0}", MarketData.GetSeries(TimeFrame.Monthly).OpenTime.LastValue.ToString("ddd, dd/MMM/yyyy, HH:mm"));
            Print("Weekly TF, Last OpenTime = {0}", MarketData.GetSeries(TimeFrame.Weekly).OpenTime.LastValue.ToString("ddd, dd/MMM/yyyy, HH:mm"));
            Print("Indicator TF = {0}", TimeFrame);
        }

        public override void Calculate(int index)
        {
        }
    }
}

If you run it on various TFs it will show various last bar missing on the Weekly and Monthly data series (only two I tested). For example, I first run it on hourly and this is what I get:

both weekly and monthly last bars are missing. When I refresh the chart, all of the sudden, monthly TF gets fixed but weekly stays incomplete:

however, switching to another TF and back to hourly makes both series incomplete again.

Am I doing something wrong or is it really a bug? It works the same way on my broker's v3.3 as well as the public beta v3.5. I did not test other TFs but they might be affected as well.

 


@VitoCz
Replies

VitoCz
30 Mar 2019, 20:38

One important info I forgot to state:

This error appears when using USTEC symbol (US TECH 100 on the demo) only. I did not realize it was symbol-specific. The other symbols seems to work fine. However, the last bars are not missing on the USTEC chart itself when I use weekly or monthly TF, only when I read the series using the GetSeries() method.


@VitoCz

VitoCz
01 Apr 2019, 11:04

So to give a complete information I've made some tests during the weekend and today. As a new month and week strated today I could actually verify, that the problem still persists even with a new  monthly/weekly bar created in the data series. I tested all symbols my broker offers for missing the last weekly or monthly bar.

Consistently, I fould missing last weekly and monthly candles in USTEC and EURUSD (!) symbol data returned by the GetSeries() method.

Both symbols were missing these candles in my previous as well as current month's tests (= in March the March bar was missing, today March candle appears but April one is missing)

When I look at the weekly and monthly charts of both symbols, the candles appear normally, so it does not seem to be a data feed issue of the broker

I will appreciate any response regarding this pottential bug

Thank you!


@VitoCz

VitoCz
01 Apr 2019, 14:27

Dear Spotware team,

the more I test the above described bug the more affected symbols and time frames I find.

So far I was focused on Daily, Weekly and Montly only as those TFs I use in my indicator. Now I performed some test on shorter TFs and found out that virtually ALL symbols are affected on shorter TFs. Most frequently I found missing bars on hour, hour2, hour3, hour4 and hour8. (all tested symbols are open and traded)

I start thinking that this is much wider and more serious bug which affects all symbols on multiple TFs and, as such, it would deserve your high priority for investigation and fixing

Thank you 


@VitoCz

PanagiotisCharalampous
02 Apr 2019, 11:54

Hi Vitore,

Please let us know your broker.

Best Regards,

Panagiotis


@PanagiotisCharalampous

VitoCz
02 Apr 2019, 15:05

Hi Panagiotis,

I use IC Markets broker, True ECN account. But I can see similar issue with missing data (multiple symbols on hour, hour2, hour4 and hour8) in my Spotware demo account running on cTrader beta v.3.5 as well.

Thank you,
Vitore


@VitoCz

PanagiotisCharalampous
02 Apr 2019, 16:52

Hi Vitore,

Thanks we will check this.

Best Regards,

regards,


@PanagiotisCharalampous

PanagiotisCharalampous
02 Apr 2019, 17:44

Hi Vitore,

We managed to reproduce this issue and we will fix it in an upcoming version. 

Best Regards,

Panagiotis


@PanagiotisCharalampous

VitoCz
02 Apr 2019, 17:56

Hi Panagiotis,

sounds great, thanks!

Best regards,
Vitore


@VitoCz

VitoCz
04 Apr 2019, 17:31

Hi Panagiotis,

today I noticed a similar issue with XAUUSD data from the FxPro broker.  Again the last bars are missing on various Time Frames after I open a new chart with this symbol or change the chart's TF. After manual refresh the data seems to get fixed until the next automatic update of the chart (either by one of the indicators gets modified, or the chart TF is changed etc.)

Best regrads,
Vitore

 


@VitoCz

PanagiotisCharalampous
04 Apr 2019, 17:36

Hi Vitore,

The issue is fixed after the first tick arrives. It appears only on the initialization of the indicator. Maybe this can help you with a workaround e.g. wait for a tick to arrive and then get the series.

Best Regards,

Panagiotis


@PanagiotisCharalampous

VitoCz
04 Apr 2019, 18:12

Hi Panagiotis - thank you for this hint, it seems to work. Actually now rather call the method (and test for the missing bars) every time i need it (which is not with every tick but with every new index). Does calling the GetSeries method repeatedly affect the performance? I mean, is it implemented as just a pointer to the data or does it always e.g. transfers/recalculates all the data?

Thank you,
Vitore


@VitoCz

PanagiotisCharalampous
05 Apr 2019, 09:47

Hi Vitore,

It should not affect performance since the downloaded series are cached.

Best Regards,

Panagiotid


@PanagiotisCharalampous