dayShift backwards and forwards

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #203417 quote
    dimi-tree
    Participant
    New

    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!

    #203421 quote
    JS
    Participant
    Senior

    Hi @dimi-tree

    What you can try is:

    If Date = 20221031 then
    Here your conditions…
    EndIf

    #203422 quote
    JS
    Participant
    Senior

    Hi @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)

    #203467 quote
    PeterSt
    Participant
    Master

    If you stay in the same month,

    Hi @JS,

    Why this “condition” ?
    20221015 + 40 does not work ?

    #203488 quote
    JS
    Participant
    Senior

    Don’t know what’s going on but the whole “Date” thing doesn’t work right at all anymore…

    PeterSt thanked this post
    #203494 quote
    robertogozzi
    Moderator
    Master
    20221015 + 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.
    PeterSt thanked this post
    #203518 quote
    PeterSt
    Participant
    Master
    Maths 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 !?
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

dayShift backwards and forwards


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
dimi-tree @dimi-tree Participant
Summary

This topic contains 6 replies,
has 4 voices, and was last updated by PeterSt
3 years, 3 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/02/2022
Status: Active
Attachments: No files
Logo Logo
Loading...