Not opening trades on Sunday

Forums ProRealTime English forum ProBuilder support Not opening trades on Sunday

  • This topic has 3 replies, 2 voices, and was last updated 2 years ago by avatarGaby.
Viewing 4 posts - 1 through 4 (of 4 total)
  • #204125

    Hello,

    in order to avoid to open any position on Sunday I have coded the following (Sunday = 0):

    DayCond = OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 5
    TimeCond = OpenTime <= 204500 AND OpenTime >= 014500

    IF TimeCond and DayCond THEN

    However the algo managed to open a position on Sunday. DO you know why the DayCond was disregarded by Prorealcode?

    Many thanks for your help, Gaby

     

     

     

     

     

     

    #204137

    Maybe you are placing a pending order on the very last candle on Friday, so it will be executed when the next bar opens, which might be on Sunday.

    This code works correctly:

    #204179

    Thanks Roberto, you spot on!

    It was a daily signal started on Fri @ 00.00.00 and given at the closure of the bar (on Friday day’s close). And the program correctly took the trade as soon as possible (Sunday @ 21.00 GMT).

    Actually, I made a mistake on my first message, as in my first post analysis I did not see it was a daily signal. The daily program includes only the check on the DayCond (and not the TimeCond).

    I have now modified my code as follow – and it works (it now prevent trading on Sunday evening at the opening to execute signals generated on Friday’s close):

    // Avoid to open new trades on Sunday at 21.00.00 (for signals generated on Friday’s close), to avoid wide spreads on Sunday night
    // Avoid to open new trades on Monday at 00.00.00 (for signals generated on Sunday’s close), to avoid to consider Sunday as a relevant day to generate the signal.
    DayCond = OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 5
    Sunday = DayOfWeek[0]
    IF DayCond AND NOT Sunday THEN

    Thank you for your support. Gaby

    #204180

    ========= ERRATA CORRIGE ========

    This is the code that works (preventing trades to be opened on Sunday):

    // Avoid to open new trades on Sunday at 21.00.00 (for signals generated on Friday’s close), to avoid wide spreads on Sunday night
    // Avoid to open new trades on Monday at 00.00.00 (for signals generated on Sunday’s close), to avoid to consider Sunday as a relevant day to generate the signal.
    DayCond = OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 5
    NoSunday = currentdayofweek=1 or currentdayofweek=2 or currentdayofweek=3 or currentdayofweek=4 or currentdayofweek=5

    IF DayCond and NoSunday THEN

Viewing 4 posts - 1 through 4 (of 4 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login