Number of trading days per month

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #120103 quote
    MagifinaMagifina
    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
    VonasiVonasi
    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
    MagifinaMagifina
    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
    VonasiVonasi
    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.
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

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 VonasiVonasi
6 years, 7 months ago.

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