Wont BUY First day of month if its a Monday 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #157164 quote
    Nobody
    Participant
    Veteran

    Wont BUY First day of month if its a Monday

     

    I noticed inconsistent proorder behaviour with the following code:

    if not longonmarket and month = 11 then
    buy 1 contract at market
    endif
    
    if month <> 11 then
    sell at market
    endif

     

    The above code is intended to buy the first bar of Nov and sell after month end.

    Bug: If the first bar of the month is a Monday, the signal trigger a bar late.

    ScreenShot2835.jpg ScreenShot2835.jpg ScreenShot2834.jpg ScreenShot2834.jpg
    #157167 quote
    robertogozzi
    Moderator
    Master

    Because Month is the month when a bar closes, while OpenMonth when a bar opens.

    So if Oct.31st is when market is closed there’s no bar and the beginning of the next month cannot be detected until the nexr bar closes, that is when the Monday bar closes in this case.

    But it would be the same on a, say,Wednesday if the previous day markets were closed.

    #157168 quote
    Nobody
    Participant
    Veteran

    Not going to be hard for PRT to code that in . Its all known in advance . Just makes a seasonal monthly test inaccurate  .  i think PRT CAN solve it , its just whether they want to   .   Anyway now anyone knows buying month = is getting flawed results  .

     

    I did note Nicholas wrote a last trading day of month code somewhere before , will see if i can find it . Maybe a first trading day of month companion code can be written

    #157169 quote
    KDH
    Participant
    New

    I have encountered this same issue and it is frustrating.

    Can anyone suggest 100% working code for how to buy on the open on the first day of the month?

    #157170 quote
    Vonasi
    Moderator
    Master

    Brisvegas – Your post has been edited.

    • Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
    #157171 quote
    Vonasi
    Moderator
    Master

    Can anyone suggest 100% working code for how to buy on the open on the first day of the month?

    Use MTF to get you on the market at the opening of the 2nd 1 second candle of the month.

    timeframe (1 second)
    if openmonth <> openmonth[1] then
    buy 1 contract at market
    endif
    

     

    Not tested.

    KDH thanked this post
    #157269 quote
    Nicolas
    Keymaster
    Master

    Last day of trading of the month code snippet and explanation can be found here: https://www.prorealcode.com/topic/coding-help/#post-46525

    Link to many other useful snippets: https://docs.google.com/spreadsheets/d/1rgboqj7sVwsP9ZRhOduOefye48QMWC07jWVXCl-KJPU/edit#gid=0

    Nobody and KDH thanked this post
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Wont BUY First day of month if its a Monday 


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Nobody @brisvegas Participant
Summary

This topic contains 6 replies,
has 5 voices, and was last updated by Nicolas
5 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/10/2021
Status: Active
Attachments: 2 files
Logo Logo
Loading...