Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join “Do More With Qlik” with Mike Tarallo to get a first-hand look at the New Authoring Experience, June 29th: REGISTER HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
wardzynski
Creator
Creator

Time intervalls with a defined time start time each day

I need a column inside a straight table, that can based on the EntryTime of the trade, tell me the starting time of the candle bar where the trade occurs.

Example: 8 minute bars, start counting bars from 3:30 PM

Trade:         Entry Time:                             Starting time of Bar:

1                 4/4/2017 5:04:00 PM               4:58 PM

2                 4/18/2017 8:16:06 PM             8:10 PM

My session starts at 3:30PM (Field value), and based on the time-frame (8 minutes, 15 minutes, etc, also field value) it should tell you the start-time of the Bar that the trade belongs to.

For 8 min time-frame: First bar starts at 3:30 PM, then next at 3:38 PM, 3:46 PM, 3:54 PM,etc...

For 10 min time-frame: First bar starts at 3:30 PM, next 3:40 PM, 3:50 PM, etc..

For 13 min time-frame: First bar starts at 3:30 PM

Time-frame value comes from Time-frame field (8 min, 9 min, etc...)

Session start time comes from session field (3:30 PM, 8:30 AM, etc...)


This is currently how I have tried scripting it inside the straight table chart:

=time(floor(EntryTimeII,8/24/60)+maketime(0,2,0),'hh:mm:ss TT')

But it is not correct.

20 Replies
sunny_talwar

Is the timeframe decided before the reload, or is this something users will have the options to decide on the fly? If it is on the fly, then may be it makes sense to do all the calculation in the front end...

Capture.PNG

Your calculated dimension will look like this

=Time(Floor(StartTime) + Time(MakeTime(15, 30) + Floor(Frac(StartTime - MakeTime(15, 29, 59)), vTime/1440)))

Where vTime is determined by the selection you make in the input box's drop down....

wardzynski
Creator
Creator
Author

Hi Sunny,

Yes, the time-frame will be changed in the front-end, so not only 8 min is applicable.

Also, the starting time needs to be changed in the front-end.

Currently, these come from Field-values (8min, 9min, 10min, etc..) and start-time (3:30 PM or 9:30 PM, etc...)

Just so I dont confuse:

There is a start time of the day where the bars are starting from, like 3:30 PM or 9:30 PM, and there are the particular starting times for each trade in the column StartTime.

Does Maketime(15,30) together with Maketime(15,29,59) indicate the 3:30 PM initial starting time?

sunny_talwar

So, I would suggest using the above mentioned technique... did you check it yet?

wardzynski
Creator
Creator
Author

Hi Marco,

This is also working.

So, all I need is to change the '00:08' to select a different time-frame and 15:30 to select a different initial starting time?

wardzynski
Creator
Creator
Author

What I have right now:

!

sunny_talwar

Does Maketime(15,30) together with Maketime(15,29,59) indicate the 3:30 PM initial starting time?

That is right

sunny_talwar

So what in here would like to change?

MarcoWedel

Yes, that would be all.

On the other hand, I noticed some rounding issues in this solution that might lead to unexpected behaviour, e.g. 3:54:00 PM being rounded off to 3:46:00 PM.


hope this helps nevertheless


Marco

wardzynski
Creator
Creator
Author

So if I get my initial starting time (3:30 PM) from a Field, then I would need to split it into mins and sec, and also mm:ss - 1 sec or such?

wardzynski
Creator
Creator
Author

Thats unfortunate, as your solution seemed so simple. No rounding errors are acceptable here