TimeSeries Interface Example

Created at 01 Nov 2015, 20:53
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!
aimerdoux's avatar

aimerdoux

Joined 07.06.2015

TimeSeries Interface Example
01 Nov 2015, 20:53


Hello, Can you please upload the API with an example of how to implement the interface TimeSeries, or post it over here, thank you...


@aimerdoux
Replies

aimerdoux
03 Nov 2015, 16:20

????


@aimerdoux

Spotware
03 Nov 2015, 22:55

Dear Trader,

Please have a look at the TimeSeries section of our API Reference.


@Spotware

aimerdoux
04 Nov 2015, 00:00

yes sure i have done that, it is exactly the reason why i would like you to show an example of it, i only see in the API the list of items inside of the interface index, last, count, etc but no exmaple to show how is the implementation


@aimerdoux

aimerdoux
04 Nov 2015, 16:46

RE:

Spotware said:

Dear Trader,

Please have a look at the TimeSeries section of our API Reference.

im begging I really need I tried to implement it as IndicatorDataSeries but somehow some of the values become NeuN so please write an example of TimeSeries here, Do i have to initialize the Time Series like  this? 

public TimeSeries Series;

 

OnStart()

 

Series= CreateDataSeries();

 

OnTick()

Series[MarketSeries.Close.Count-1]= marketSeries.Close.Last(0)/ MarketSeries.Close.Last(1);

 

This is an example of how you do an InicatorDataSeries implementation posted on API please provide one to TimeSeries Due that if not is kind of impossible to implement it... thank you

 


@aimerdoux

Spotware
05 Nov 2015, 03:22

Dear Trader,

Please have a look at the following code snippet:

        protected override void OnStart()
        {

            TimeSeries series = MarketSeries.OpenTime;

            //Gets the number of elements contained in the series.
            int count = series.Count;

            //Gets the last value of this time series.
            string date = series.LastValue.ToString();

            //Returns the DateTime value at the specified index.
            string date2 = series[count - 10].ToString();

            //Access a value in the dataseries certain bars ago
            string date3 = series.Last(5).ToString();


            MarketSeries marketSeriesMin30 = MarketData.GetSeries(TimeFrame.Minute30);

            //Find the index in a different time frame series
            int index1 = series.GetIndexByExactTime(marketSeriesMin30.OpenTime.LastValue);

            //Find the index in a different time frame series
            int index2 = series.GetIndexByTime(marketSeriesMin30.OpenTime.LastValue);

            //The difference between the two is that GetIndexByTime returns the closest index to the open time, 
            //whereas the GetindexbyExactTime will only return an index if there is one at the exact time and will return -1 otherwise.

            Print("count {0}, date {1}, date2 {3}, index1 {4}, intex2 {5}.", count, date, date2, date3, index1, index2);
        }

We hope this helps you.


@Spotware