Next trading day

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #35696 quote
    DespairDespair
    Blocked
    Master

    How do i manage the following problem:

     

    Say i have a daily strategy and want to buy every month on the 10th or the next trading day in case the 10th is a holiday/weekend.  In the datafeed of the security the non-tradingday simply do not exist. So if the 10th is for example a sunday the datafeed jumps from friday 8th directly to monday 11th.

    Any ideas how i can accomblish this conveniently?

    #35703 quote
    NicolasNicolas
    Keymaster
    Legend

    I coded something similar recently for Doctrading, about finding the last day of month: https://www.prorealcode.com/topic/astuce-dernier-jour-du-mois/page/2/

    At the beginning of the thread, you can find this code snippet that will give you the day of the week number by looking with its date:

    //find the day number with a date
    myYear=2017
    myMonth=2
    myDay=13
    
    if myMonth >= 3 then
    D = (((23*myMonth)/9) + myDay + 4 + myYear + (myYear/4) - (myYear/100) + (myYear/400) - 2) mod 7
    else
    z = myYear - 1
    D = (((23*myMonth)/9) + myDay + 4 + myYear + (z/4) - (z/100) + (z/400) ) mod 7
    endif
    
    return D

    It’s the Keith algorithm. So if the D value is a Sunday for the 10th day of the month you look at, then you know you have to adapt the strategy to trade the next day.. Hope I’m clear 🙂

    Despair thanked this post
Viewing 2 posts - 1 through 2 (of 2 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

Next trading day


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Despair @despair Blocked
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by NicolasNicolas
9 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/16/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...