Sunday bars

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #30183 quote
    dvdroversdvdrovers
    Participant
    New

    Hi all,

    Just finding my feet with this system so have a simple question. Is there anyway to ignore the sunday bar when backtesting? I know I can remove it from the charts however it appears that when i write a rule and backtest it still takes it into account. Thanks for your help.

    #30218 quote
    NicolasNicolas
    Keymaster
    Legend

    Do you want the Sunday bar to be ignored by indicators calculation? or just avoid Sunday to not launch any order?

    #30266 quote
    dvdroversdvdrovers
    Participant
    New

    Hi Nicolas,

    My strategy entry is on the previous bars high so i ideally want to be able to backtest without the sunday bar being factored in. Is this possible?? I have worked out how not to trade on the sunday bar. Thanks for the reply.

    #30471 quote
    NicolasNicolas
    Keymaster
    Legend

    If you are using the previous day High to decide your entry condition, just add a comparison with the day of the week to know you are not using the Sunday bar:

    if DayOfWeek[1]=7 then 
     myHigh = High[2] //store friday high is yesterday was Sunday
    else
     myHigh = High[1] //else we store the previous day high
    endif

    Then use myHigh value in your conditional statement instead of High. Hope it is clear.

    robertogozzi thanked this post
    #33615 quote
    C Y KohC Y Koh
    Participant
    New

    Hi Nicolas,

    I have a similar requirement to ignore Sunday bars.. Ideally My strategy is affected by the Sunday bars as (1) I count the number of preceding bars for re-entry   (2) I use daily closes.

    Is there a way to backtest without Sunday Bars?

    I used DayOfWeek to overcome the situation, but there’s an error.  Please look at my screenshot.  I “graph DayofWeek”.  Thursdays, Fridays and Sundays all return the value of 5.. Is there a bug?

     

    Thanks!

    CY

    Screen-Shot-2017-04-27-at-12.04.38-PM.png Screen-Shot-2017-04-27-at-12.04.38-PM.png
    #33665 quote
    NicolasNicolas
    Keymaster
    Legend

    Are you in a Weekly timeframe?

    Also, a quick tip to get the day of the week when the bar has opened, is to use OpenDayOfWeek instead.

    #33937 quote
    C Y KohC Y Koh
    Participant
    New

    Hi Nicolas,

    Thanks for the info!

    I’m using Daily bars.

    I’ve swapped OpenDayofWeek for DayofWeek.  It works better now, with Monday = 1, Tues = 2.. But both Fridays and Sundays have the value of 5..    My code is:

    IF not LongOnMarket AND Count = 3 and OpenDayofWeek <> 5 THEN
    StopLoss = close – 2 * AverageTrueRange[40](close)
    BUY PositionSize shares at market

    Endif

    That basically also rules out entering the market on Fridays too..

    Any suggestions?

    Thanks!

    CY

    #47865 quote
    stefou102stefou102
    Participant
    Veteran

    same problem for me on the 1H time frame. I have tried opendayofweek, currentdayofweek, dayofweek, all three returned 5 for a Sunday bar. So impossible currently to identify a sunday bar???

    #52658 quote
    alvestjoalvestjo
    Participant
    Junior

    Hi,

    I have the same problem. Dayofweek is not 7 for sundays in daily graphs. It must be a bug.

    However I did find a trick to identify if a bar is a sunday. The costant “Hour” is 23 when the script is run on a sunday and 1 (i think) on normal weekdays.

    //Jonas

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Sunday bars


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
dvdrovers @dvdrovers Participant
Summary

This topic contains 8 replies,
has 5 voices, and was last updated by alvestjoalvestjo
8 years, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/28/2017
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...