error whis GetIndexByTime

Created at 18 Feb 2020, 19:41
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!
TR

travkinsm1

Joined 05.04.2018

error whis GetIndexByTime
18 Feb 2020, 19:41


 This function

protected st week(int i)
        {
            st stRes;
            Print("x1");
            stRes.center = DateTime.Now.AddSeconds(-i * (60 * 60 * 24 * 7));
            Print("x2");
            DateTime dt = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
            //DateTime dt = System.TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local);
            //DateTime dt = DateTime.Now;
            Print(dt);
            if (i > 0)
                stRes.end = Bars.OpenTimes.GetIndexByTime(dt.AddSeconds(-i * (60 * 60 * 24 * 7)).AddMinutes(lookBack / 2));
            else
                stRes.end = Bars.OpenTimes.GetIndexByTime(dt.AddSeconds(-i * (60 * 60 * 24 * 7)));
            if (i > 0)
                stRes.begin = Bars.OpenTimes.GetIndexByTime(dt.AddSeconds(-i * (60 * 60 * 24 * 7)).AddMinutes(-lookBack / 2));
            else
                stRes.begin = Bars.OpenTimes.GetIndexByTime(dt.AddSeconds(-i * (60 * 60 * 24 * 7)).AddMinutes(-lookBack));
            Print(stRes.end, " ", stRes.begin);
            return stRes;
        }

whis this struct

        public struct st
        {
            public int end;
            public int begin;
            public DateTime center;
        }

print and return stRes.end=-1 and stRes.begin=-1 in test whis i=0 or i=1. lookBack>0. TimeFrame=t1.

Why? Help please.


@travkinsm1
Replies

PanagiotisCharalampous
19 Feb 2020, 08:22

Hi travkinsm1,

Please provide a complete cBot code and steps to reproduce this behavior.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

travkinsm1
19 Feb 2020, 13:54

Can I get help without revealing my code? There are more than 700 lines, but only this section does not work.


@travkinsm1

PanagiotisCharalampous
19 Feb 2020, 14:01

Hi travkinsm1,

In order to help you we need to reproduce the problem. If you can create a sample cBot that reproduces the issue, that would help.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

travkinsm1
21 Feb 2020, 17:12

I got the point. It was necessary to load the trading history


@travkinsm1