Number of trading days per month

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #120103 quote
    Magifina
    Participant
    Master

    Hello,

    In order to create a strategy based on seasonality, I would like to graph a variable that returns the number of trading days per month without including sunday candles.

    I can return with the following code the number of trading days including sundays. I have tried to add a “elsif dayofweek=2 then c1=c1” but it doesn”t work.

    Can someone help me?

    Magifina

    defparam cumulateorders=false
    
    IF openday>openday[1] THEN
    c1=c1+1
    ELSE
    c1=1
    ENDIF
    
    graph c1
    // Conditions pour ouvrir une position acheteuse
    IF NOT LongOnMarket  THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    
    // Conditions pour fermer une position acheteuse
    If LongOnMarket  THEN
    SELL AT MARKET
    ENDIF
    #120104 quote
    Vonasi
    Moderator
    Master

    Try this:

    if openmonth<>openmonth[1] then
    c1 = 0
    endif
    
    if openday <> openday[1] and openday <> 0 then 
    c1 = c1 + 1
    endif
    #120105 quote
    Magifina
    Participant
    Master

    Thanks for your quick answer Vonasi. I have found the solution. In fact openday <>0 must be replace by dayofweek <> 2 in order to work.

    if openmonth<>openmonth[1] then
    c1 = 0
    endif
     
    if openday <> openday[1] and dayofweek <> 2 then
    c1 = c1 + 1
    endif
    #120106 quote
    Vonasi
    Moderator
    Master

    Sorry – I just realised my typo – we need to use OPENDAYOFWEEK and not OPENDAY. Sunday is OPENDAYOFWEEK zero.

    Better to check the open day rather than the day as if there is a bank holiday monday it will mess things up and you will count a Sunday.

    if openmonth<>openmonth[1] then
    c1 = 0
    endif
    
    if opendayofweek <> opendayofweek[1] and opendayofweek <> 0 then 
    c1 = c1 + 1
    endif
    
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Number of trading days per month


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Magifina @magifina Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Vonasi
6 years ago.

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