dayShift backwards and forwards
Forums › ProRealTime English forum › ProOrder support › dayShift backwards and forwards
- This topic has 6 replies, 4 voices, and was last updated 2 years ago by
PeterSt.
-
-
11/02/2022 at 3:15 PM #203417
Hello!
Is there a way to implement the equivalent of the CalcDate function from EasyLanguage in ProRealCode?
I want to be able to test an entry condition based on a fixed date +/- “daysShift” days.
E.g. let’s say
event = 20221031 // 31st Oct 2022
I need a way to enter the market “daysShift” days before the event.After the event, I can use the lookback, i.e.
(date = event)[1]
… and I want something for lookforward.
Any ideas?Thanks!
11/02/2022 at 3:47 PM #20342111/02/2022 at 3:59 PM #203422Hi @dimi-tree
If you stay in the same month, you can also move the days forwards or backwards…
If Date = 20221015 + 15 then (equals 20221030)
If Date = 20221015 – 13 then (equals 20221002)11/03/2022 at 8:39 AM #20346711/03/2022 at 5:42 PM #20348811/03/2022 at 6:33 PM #20349420221015 + 40 equals 20221055. There’s no day 55!
Maths on dates & times is a bit difficult to do, as you first have to compare if the sum exceeds the last day of the month, if yes, then compute the remaining days, increase the month (two middle digits) checking that it doesn’t exceed 12 (otherwise you also need to increase the year, the leftmost 4 digits), then add the remaining days to the new date and so on… until the remaining days total 0.
1 user thanked author for this post.
11/04/2022 at 12:53 PM #203518Maths on dates & times is a bit difficult to do
Sadly I am more than aware of this throughout my “life”. But easy to do once you are used to it.
Don’t know what’s going on but the whole “Date” thing doesn’t work right at all anymore…
I seriously thought this worked nicely in PRT, but maybe I dreamed it !?
-
AuthorPosts