Trigger Strategy at specific times

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #178407 quote
    adeelq79
    Participant
    Junior

    Hi,

    Id like to modify my code to trade between 2 specific time frames per day; I’d like the system to be active from:
    1) 2:30pm – 6pm and;
    2) 8:15pm – 830pm.

    I’d like to have flexibility to change this of course.

    Can anyone help?

    Thanks

    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 143000
    timeEnterBefore = time >= noEntryBeforeTime
    
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 203000
    timeEnterAfter = time < noEntryAfterTime
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    //timeframe (10 minute, updateonclose)
    
    //max orders each day
    
    if intradaybarindex=0 or day<>day[1] then
    
    orderscount=0
    
    endif
    
    allowtrading=orderscount<maxDayOrder and timeenterbefore and timeenterafter and not daysforbiddenentry
    #178409 quote
    robertogozzi
    Moderator
    Master

    Try this one  (not tested):

    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 143000
    timeEnterBefore = time >= noEntryBeforeTime
    noEntryBeforeTime2 = 201500
    timeEnterBefore2 = time >= noEntryBeforeTime2
    
     
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 180000
    timeEnterAfter = time < noEntryAfterTime
    noEntryAfterTime2 = 203000
    timeEnterAfter2 = time < noEntryAfterTime2
    
     
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
     
    //timeframe (10 minute, updateonclose)
     
    //max orders each day
     
    if intradaybarindex=0 or day<>day[1] then
     
    orderscount=0
     
    endif
     
    allowtrading=orderscount<maxDayOrder and ((timeenterbefore and timeenterafter) or  (timeenterbefore2 and timeenterafter2))   and not daysforbiddenentry
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Trigger Strategy at specific times


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
adeelq79 @adeelq79 Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/25/2021
Status: Active
Attachments: No files
Logo Logo
Loading...