Trendbars parameters fromTimestamp and toTimestamp

viniciusfre since: 28 Dec 2018;

  11 Jan 2021, 02:56
Trendbars parameters fromTimestamp and toTimestamp

Hello,

I am trying to test PROTO_OA_GET_TRENDBARS_REQ but I did not figure out the correct format parameters for fromTimestamp and toTimestamp. 

The documentation says milliseconds, but in stream I am receiving milliseconds converted to minutes so I was trying that format.

Example trendbar for SubscribeLiveTrendbar: 

volume: 14
low: 1.22176
open: 1.22216
close: 1.22176
high: 1.22236
timestamp: 26838625 <--- (milliseconds to minutes)

My C++ code to get 20 M5 trendbars candles starting at current time:

minutes now = duration_cast<minutes>(system_clock::now().time_since_epoch());
timestamp = now.count();
cout << "timestamp = " << timestamp << endl;
GetTrendBars(timestamp - 20, timestamp, M5, symbolID);

But I am not getting anything except a empty PROTO_OA_GET_TRENDBARS_RES.

Could someone give me examples of correct format parameters? Thanks.

PanagiotisCharalampous's avatar

PanagiotisCharalampous since: 13 Jan 2017;

  11 Jan 2021, 09:41

Hi viniciusfre,

As per the documentation, the format is milliseconds. You can check our .Net Sample.

Best Regards,

Panagiotis 

Join us on Telegram

Head of Community Management at cTrader

viniciusfre since: 28 Dec 2018;

  11 Jan 2021, 13:31
RE:

PanagiotisCharalampous said:

Hi viniciusfre,

As per the documentation, the format is milliseconds. You can check our .Net Sample.

Best Regards,

Panagiotis 

Join us on Telegram

Hi,

I finally figured out the format. it is Unix timestamp in millseconds. Example: from = 1610330400000 to = 1610331300000

I think if the documentation make clear about Unix timestamp in milliseconds, it will help to understand better.

Thanks.

viniciusfre since: 28 Dec 2018;

  12 Jan 2021, 10:48
RE: RE:

viniciusfre said:

PanagiotisCharalampous said:

Hi viniciusfre,

As per the documentation, the format is milliseconds. You can check our .Net Sample.

Best Regards,

Panagiotis 

Join us on Telegram

Hi,

I finally figured out the format. it is Unix timestamp in millseconds. Example: from = 1610330400000 to = 1610331300000

I think if the documentation make clear about Unix timestamp in milliseconds, it will help to understand better.

Thanks.

Now I have another issue. I am trying to request 20 or 150 trendbars in M5 period but I only receives sometimes 6, 5 or even 2. For example, for 20 trendbars:

from = 1610434500000; to = 1610440500000
TrendBarRes size = 6 <----

close1: 1.21969
close2: 1.21634
close3: 1.21746
close4: 1.21672
close5: 1.22012
close6: 1.21624

That is 'Tue Jan 12 2021 06:55:00' to 'Tue Jan 12 2021 08:35:00', i.e. 100 minutes / 5 = 20 candles/trendbars. Is there something wrong in the request?

PanagiotisCharalampous's avatar

PanagiotisCharalampous since: 13 Jan 2017;

  12 Jan 2021, 16:50

Hi viniciusfre,

I tried this using the sample project and I get 21 bars.

Make sure there are no issues in your code

Best Regards,

Panagiotis 

Join us on Telegram

Head of Community Management at cTrader

viniciusfre since: 28 Dec 2018;

  13 Jan 2021, 22:30
RE:

PanagiotisCharalampous said:

Hi viniciusfre,

I tried this using the sample project and I get 21 bars.

Make sure there are no issues in your code

Best Regards,

Panagiotis 

Join us on Telegram

Looks like I have an issue in my read function. Could please tell me the first 5 or 6 close prices? I dont have PCs with VS to test.

PanagiotisCharalampous's avatar

PanagiotisCharalampous since: 13 Jan 2017;

  14 Jan 2021, 08:41

Hi viniciusfre,

Here you go

Trendbars{Open: 2
High: 46
Low: 121568
Close: 41
Timestamp: 26840575
Open: 42
High: 43
Low: 121564
Close: 5
Timestamp: 26840580
Open: 16
High: 28
Low: 121554
Close: 20
Timestamp: 26840585
Open: 2
High: 39
Low: 121572
Close: 9
Timestamp: 26840590
Open: 0
High: 50
Low: 121580
Close: 45
Timestamp: 26840595
Open: 0
High: 43
Low: 121624
Close: 39
Timestamp: 26840600
Open: 2
High: 30
Low: 121662
Close: 23
Timestamp: 26840605
Open: 12
High: 79
Low: 121674
Close: 13
Timestamp: 26840610
Open: 44
High: 48
Low: 121644
Close: 1
Timestamp: 26840615
Open: 5
High: 32
Low: 121641
Close: 15
Timestamp: 26840620
Open: 43
High: 44
Low: 121614
Close: 6
Timestamp: 26840625
Open: 40
High: 46
Low: 121581
Close: 18
Timestamp: 26840630
Open: 0
High: 59
Low: 121599
Close: 36
Timestamp: 26840635
Open: 76
High: 96
Low: 121559
Close: 80
Timestamp: 26840640
Open: 79
High: 80
Low: 121561
Close: 29
Timestamp: 26840645
Open: 64
High: 64
Low: 121524
Close: 24
Timestamp: 26840650
Open: 42
High: 60
Low: 121506
Close: 3
Timestamp: 26840655
Open: 0
High: 52
Low: 121506
Close: 46
Timestamp: 26840660
Open: 0
High: 61
Low: 121549
Close: 37
Timestamp: 26840665
Open: 13
High: 33
Low: 121575
Close: 30
Timestamp: 26840670
Open: 2
High: 69
Low: 121602
Close: 32
Timestamp: 26840675
}}

Best Regards,

Panagiotis 

Join us on Telegram

Head of Community Management at cTrader

viniciusfre since: 28 Dec 2018;

  19 Jan 2021, 14:48
RE:

PanagiotisCharalampous said:

Hi viniciusfre,

Here you go

Trendbars{Open: 2
High: 46
Low: 121568
Close: 41
Timestamp: 26840575
Open: 42
High: 43
Low: 121564
Close: 5
Timestamp: 26840580
Open: 16
High: 28
Low: 121554
Close: 20
Timestamp: 26840585
Open: 2
High: 39
Low: 121572
Close: 9
Timestamp: 26840590
Open: 0
High: 50
Low: 121580
Close: 45
Timestamp: 26840595
Open: 0
High: 43
Low: 121624
Close: 39
Timestamp: 26840600
Open: 2
High: 30
Low: 121662
Close: 23
Timestamp: 26840605
Open: 12
High: 79
Low: 121674
Close: 13
Timestamp: 26840610
Open: 44
High: 48
Low: 121644
Close: 1
Timestamp: 26840615
Open: 5
High: 32
Low: 121641
Close: 15
Timestamp: 26840620
Open: 43
High: 44
Low: 121614
Close: 6
Timestamp: 26840625
Open: 40
High: 46
Low: 121581
Close: 18
Timestamp: 26840630
Open: 0
High: 59
Low: 121599
Close: 36
Timestamp: 26840635
Open: 76
High: 96
Low: 121559
Close: 80
Timestamp: 26840640
Open: 79
High: 80
Low: 121561
Close: 29
Timestamp: 26840645
Open: 64
High: 64
Low: 121524
Close: 24
Timestamp: 26840650
Open: 42
High: 60
Low: 121506
Close: 3
Timestamp: 26840655
Open: 0
High: 52
Low: 121506
Close: 46
Timestamp: 26840660
Open: 0
High: 61
Low: 121549
Close: 37
Timestamp: 26840665
Open: 13
High: 33
Low: 121575
Close: 30
Timestamp: 26840670
Open: 2
High: 69
Low: 121602
Close: 32
Timestamp: 26840675
}}

Best Regards,

Panagiotis 

Join us on Telegram

Hi Panagiotis,

I finally figured out the issue. In my read function I was using ParseFromString and it was getting corrupted payload. The correct function is ParseFromArray, after that worked fine.

Thanks for your help and support.