Ignore sunday bar

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #43224 quote
    Derek
    Participant
    Veteran

    It’s currentdayofweek not dayofweek.

    Or am I off track?

    #43227 quote
    AVT
    Participant
    Senior

    CurrentDayOfWeek is for the current candle, wheras DayOfWeek can be any candle you specify (like finding out whether the 10th candle before was on a Monday=1 or not)

    #43230 quote
    robertogozzi
    Moderator
    Master

    This seems to be the good one (on Eur/Usd, DAILY, on Dax it still opens trades on Sunday, occasionally):

    Defparam cumulateorders = false
    //                   Long
    IF CurrentDayOfWeek = 4 AND close < open THEN        //On Friday we test Thursday's close
       Buy 1 contract at market                          //and a new trade should be opened immediately (on
    ENDIF                                                //Friday).
    //                   Short
    IF CurrentDayOfWeek = 0 AND close[1] > open[1] THEN  //On Monday we need to test the Fridays'closure, since
       sellshort 1 contract at market                    //there is Sunday in the middle.
    ENDIF
    //GRAPH CurrentDayOfWeek AS "cDoW"
    //             Stop e target in pips
    SET TARGET pPROFIT 75
    SET STOP   pLOSS   35

    The strategy tests Thursday to open a new trade on Friday and Friday (on Sunday BAR) to open a new trade on Monday, if conditions are met.

    Nicolas thanked this post
    #43244 quote
    Nicolas
    Keymaster
    Master

    When testing daily bar, you should use OpenDayOfWeek

    robertogozzi and Derek thanked this post
    #43253 quote
    robertogozzi
    Moderator
    Master

    Still Nicolas, I need to know some (unknown to me) details: “when are DayOfWeek, CurrentDayOfWeek and OpenDayOfWeek best used?”.

    Because, as you can see from the screenshot (EurUsd daily), on Thursday DoW is 5 while the other two are both 4, on Friday all the three retain value 5 and on Monday DoW is 2 while the other two are both 1. It appears that DoW is always one day ahead, but on Friday!  What’s the logic behind this?

    AVT and Derek thanked this post
    Pic-Th-Fr-Mo.jpg Pic-Th-Fr-Mo.jpg
    #44256 quote
    Derek
    Participant
    Veteran

    Hello robertogozzi,

    take a look a the attached screenshot for this code:

    dow = DayOfWeek
    CDow = CurrentDayOfWeek
    ODow = OpenDayOfWeek
    
    return dow as "dow", CDow as "CDow", ODow as "ODow"

    “CDow” is always referring to the same day which is Friday and not the actual Sunday of the day when I took the screenshots. Trying CDow on a IG Market that actually trades on Sundays did not change the observation.

    Dow” is counting from 1 on Sundays to 5 on Thursday and remains 5 on Friday.

    ODow is working properly.

    I guess this helps to decide which function to use.

    Screenshot-2.png Screenshot-2.png Screenshot-3.png Screenshot-3.png
    #44259 quote
    Derek
    Participant
    Veteran

    The good news is: All three are working fine on the intraday timerframes. The screenshot shows an hourly t-bond futures chart.

    Here currentdayofweek switches to the new day faster. The rest of the day currentdayofweek and opendayofweek are identical,

    Screenshot-4.png Screenshot-4.png
    #44321 quote
    Derek
    Participant
    Veteran

    And I have to correct myself:

    On intraday timeframes currentdayofweek works just the same as on longer timeframes.

    It’s dayofweek that switches to the new day on the first intraday bar. Openday of week waits for the first bar to close, before returning the next day’s value.

    Sorry for the confusion.

    robertogozzi thanked this post
Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.

Ignore sunday bar


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Pjotterd @pjotterd Participant
Summary

This topic contains 22 replies,
has 5 voices, and was last updated by Derek
8 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/09/2017
Status: Active
Attachments: 9 files
Logo Logo
Loading...