GetIndexByTime error

Created at 12 May 2022, 12:56
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!
GA

GabrielContiniDallmann

Joined 22.09.2017

GetIndexByTime error
12 May 2022, 12:56


Hi,

I am trying to use the Getindexbytime function to get the index of the 1 minute chart, and see that when I move up the period of the current graph, the function does not return the correct opening time.

Ex: 1 hour chart and getting the opening of 1 minute chart

Ex: 2 hour chart and getting the opening of 1 minute chart

To get the 1 minute index i use this: var indexData = _data.OpenTimes.GetIndexByTime(Bars.OpenTimes[Chart.FirstVisibleBarIndex]);

Is this normal or could this be some kind of mistake in my code?

Thanks!


@GabrielContiniDallmann
Replies

amusleh
13 May 2022, 10:19

Hi,

GetIndexByTime method returns the nearest bar index based on the date time you passed to it, if there is no bar for your passed date time then it will return -1.

Please post a indicator/cBot code sample that can reproduce the issue, then we will be able to help you.

 


@amusleh