Strategies action timeframe

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #212077 quote
    Edoardo
    Participant
    New

    Hello guys.

    If I wanted to modify one or more strategies that are on this site by limiting the action timeframe (for example: only trading from Monday to Friday, from 08:30 to 12:00 and from 14:00 to 18:00), how should I proceed with the code?

    In other words, (i) is there a standard formula to use (copy and paste), and (ii) in which part of the code should I exactly paste this formula (at the end before the closing formula)?

    Thanks in advance.

    Edo

    #212078 quote
    robertogozzi
    Moderator
    Master

    There you go:

    ONCE startT = 000000               //Starting TIME
    ONCE endT   = 240000               //Ending TIME
    TimeRef     = OpenTime             //replace with TIME if needed
    DayRef      = OpenDayOfWeek        //replace with DAYOFWEEK if needed
    //
    td0         = 0 AND DayRef = 0 AND TimeRef >= startT AND TimeRef <= endT //Sun
    td1         = 1 AND DayRef = 1 AND TimeRef >= startT AND TimeRef <= endT //Mon
    td2         = 1 AND DayRef = 2 AND TimeRef >= startT AND TimeRef <= endT //Tue
    td3         = 1 AND DayRef = 3 AND TimeRef >= startT AND TimeRef <= endT //Wed
    td4         = 1 AND DayRef = 4 AND TimeRef >= startT AND TimeRef <= endT //Thu
    td5         = 1 AND DayRef = 5 AND TimeRef >= startT AND TimeRef <= endT //Fri
    td6         = 0 AND DayRef = 6 AND TimeRef >= startT AND TimeRef <= endT //Sat
    tdCond      = td0 OR td1 OR td2 OR td3 OR td4 OR td5 OR td6

    Days are identified from 0 (Sunday) through 6 (Saturday), to disable, say WEDNESDAY, set td3 = 0.

    Add tdCond to your entry conditions.

    Edoardo and Midlanddave thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Strategies action timeframe


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Edoardo @sparrowhawk Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
2 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/24/2023
Status: Active
Attachments: No files
Logo Logo
Loading...