In a custom indicator i am developing, I am trying to determine % of trading day remaining- the calculation of which is relatively straightforward - number of secs remaining/ number of seconds in a trading day.
So i am using datetime() function to get the array of the datetime values. Since the trading day starts at 9:15:00 AM, i am using DatetimeDiff() function to calculate the difference between the 2 dates. this works perfectly fine, except, on fridays- (i dont know why??).
I am attaching the code and the trace output for your perusal.
Ok...so the output for each row in trace should be a datetime value with the date for that particular entry in the array and 9:15:00 am as the time part. The only place where this doesnt happen are fridays for some reason as can be seen in the trace output that i have posted - on 12/6/2020 the value being assigned is 14/6/2020 9:15 instead of 12/6/2020 9:15, same for 19/6 et al. Rest all daysvalue is in sync with the date of that array entry as in for 11/6 it is 11/6 9:15 am, 13/6 it is 13/6 9:15 and so on.
I stopped scratching my head in another thread because the member started off with a very vague description and it wasn't clear what settings/function was even being used.
It appears you might also end up going that way.
looking at your DateTime() output
12-Jun-20 9:16:59 AM dtbegin: 14-Jun-20 9:15:00 AM
15-Jun-20 9:15:59 AM dtbegin: 15-Jun-20 9:15:00 AM
you are clearly not using AB default settings and this itself will be the cause of a big misunderstanding. 9:16:59 AM this kind of time will only come if you are not using recommended setting.
like Last tick or End-time.
Why are you taking DT, converting to string then back to DT and then subtracting ?
Trying to make up for the interval loss with extra minute(s) is causing you to get new bar of Monday,
and subtracting more than the available time ending with a future date on Friday which is actually a sunday morning.
Also, a better way is to debug using Exploration, put each variable in a column and check the output. As in tabulate it properly.
so kindly get all the stuff right because as i said, manipulating non-default settings will require the user to understand Amibroker properly.