buy order on monday not working (dayofweek=1)

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #61188 quote
    Alberto Lucchese
    Participant
    Average

    Hello,

    I was trying a new strategy that requires the buy order to be executed on Mondays. I have been testing the following very basic code:

    myday=1
    if dayofweek=myday then
    buy 1 contracts at market
    endif
    if longonmarket then
    sell 1 contracts at market
    endif

    however this code does not trigger any buys, however if I use the same code and change the number of the variable “myday” to 2, 3, 4 and 5 it does triggers buy. Any reason why the buy will not be triggered on Mondays (dayofweek=1)?

    Thanks!

    #61193 quote
    robertogozzi
    Moderator
    Master

    If you use it on a Daily TF you won’t get correct values, since DAYOFWEEK  refers to the candle when your trade will be entered, it works with intraday TFs.

    I suggest you use OPENDAYOFWEEK, since it always works!

    myday=1
    if opendayofweek=myday then
       buy 1 contracts at market
    endif
    if longonmarket then
       sell 1 contracts at market
    endif
    #61240 quote
    Alberto Lucchese
    Participant
    Average

    Thank you! It worked!

    #184055 quote
    Bernieman
    Participant
    New

    I have the same problem. When I use “opendayofweek” instead “dayofweek” with opendyofweek = 1 then it works, thats true. But it opens also on Tuersday and not on Monday.  Therefore the result is the same as if i would use dayofweek = 2. But when I use opendyofweek = 0, which should refer to open a position at Monday Morning, then the result is the same like with dayofweek = 1, nothing happens.

    What could be the reason?

    Thanks

    #184058 quote
    robertogozzi
    Moderator
    Master

    Keywords starting with OPEN (OpenDate, OpenTime, OpenDayOfWeek, etc…) return the Date, Time, DayOfWeek, etc… when a candle opens, otherwise data returned are those when a candle closes.

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

buy order on monday not working (dayofweek=1)


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by robertogozzi
4 years, 1 month ago.

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