Bars.OpenTimes.GetIndexByTime(Bars.OpenTimes.LastValue).ToString() returns different values

Created at 13 Apr 2022, 16: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!
FI

firemyst

Joined 26.03.2019

Bars.OpenTimes.GetIndexByTime(Bars.OpenTimes.LastValue).ToString() returns different values
13 Apr 2022, 16:53


Hi everyone:

When I install this "test" indicator on my local machine and view a daily chart, it will return a value such as 1480. My local computer is UTC + 8

Yet, if I install this on my VPS, which is located in NEW YORK, but I have the local VPS time set to UTC + 8, it returns a different value.

From my local machine:

 

From my VPS:

Same daily time frame, same symbol - I would expect those numbers to match.

Why are they different?

 

Here's the indicator code:

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class Test : Indicator
    {

        protected override void Initialize()
        {

        }

        public override void Calculate(int index)
        {
            Chart.DrawStaticText("test", "b:" + Bars.OpenTimes.GetIndexByTime(Bars.OpenTimes.LastValue).ToString() + " i:" + index, VerticalAlignment.Top, HorizontalAlignment.Left, Color.White);
        }

    }
}

 

Thank you.

 


@firemyst
Replies

firemyst
20 Apr 2022, 04:03 ( Updated at: 21 Dec 2023, 09:22 )

Any updates @Spotware?

Hello @Spotware / @Panagiotis / @Amusleh,

Following up as haven't seen a response in regards to this.

This is AUDCAD pair on Daily timeframe. First capture below is from my local laptop in UTC+8 time; second capture is from my VPS located in New York, but set to UTC + 8 time.

Since this is the DAILY timeframe and both charts are freshly loaded (eg, cTrader just started and no scrolling has been done), I would expect bar numbers and current indexes to be the same on both charts; however as you can see, they are way off. The indicator code used is in my original post.

This tells me that cTrader initially loads different amounts of chart data depending on what machine it's running on? Are you able to confirm this?

Otherwise, why would one daily chart for AUDCAD be up to bar number 1498 and the other be up to 1654 when both charts are freshly loaded on the same day in UTC time without any historical scrolling having been done?

Thank you.

 

Capture from local laptop:

Capture from VPS on same day a few minutes apart:


@firemyst

amusleh
20 Apr 2022, 09:29

Hi,

cTrader can load different number of data on your chart, there is no fixed number of bars.

You shouldn't rely on bar index numbers to be same across different machines, use bar open times instead.


@amusleh

firemyst
20 Apr 2022, 10:27

RE:

amusleh said:

Hi,

cTrader can load different number of data on your chart, there is no fixed number of bars.

You shouldn't rely on bar index numbers to be same across different machines, use bar open times instead.

Thank you for your response and confirmation.


@firemyst