Multiple trading times per day

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #96114 quote
    Sascha
    Participant
    Average

    Hi,

    I would like to setup several trading times per day.

    With the simplified creation you can only set up one time to not trade before and one time to not trade after (ie. trade between 6am – 4pm)

    However, I would like to have no trading from midnight until 6am. Then trade from 6am – 11am. No trading between 11am-12pm. And then trading between 12pm – 5:30pm.

    I tried to create a code but it doesn’t work.  So there must be a mistake.

    Any help very much appreciated.

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    // Cancel all pending orders and close all positions at the "FLATAFTER" time
    DEFPARAM FLATAFTER = 173000
    
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryBeforeTime = 060000
    timeEnterBefore = time >= noEntryBeforeTime
    
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 11000
    timeEnterAfter = time < noEntryAfterTime
    
    noEntryBeforeTime2 = 120000
    timeEnterBefore2 = time >= noEntryBeforeTime2
    
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime2 = 173000
    timeEnterAfter2 = time < noEntryAfterTime2
    #96115 quote
    robertogozzi
    Moderator
    Master

    line 11 misses a final “0”

    #96116 quote
    robertogozzi
    Moderator
    Master

    There you go:

    IF time >= 090000 AND time <= 110000 THEN     //trade from 9 to 11
       TradingON = 1
    ELSIF time >= 130500 AND time <= 150000 THEN  //trade from 13:05 to 15
       TradingON = 1
    ELSIF time >= 163000 AND time <= 190000 THEN  //trade from 16:30 to 19
       TradingON = 1
    ELSE
       TradingON = 0                             //do not trade outside above time ranges
    ENDIF

    Add TradingON to your conditions to enter a trade.

    #96193 quote
    Sascha
    Participant
    Average

    Thank you very much Roberto!

    #108625 quote
    Fran55
    Participant
    Veteran

    Hi.

     

    I need this Code… But i need that os operation is opened un a period It will remain open when periodo is closed.

    And that can open a position un another period and accumulate with the previous one.

     

    Thanks!

    #108626 quote
    GraHal
    Participant
    Master

    Link to above Roberto code added as Log 173 here …

    Snippet Link Library

    robertogozzi thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Multiple trading times per day


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Sascha @goedelsa Participant
Summary

This topic contains 5 replies,
has 4 voices, and was last updated by GraHal
6 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/11/2019
Status: Active
Attachments: No files
Logo Logo
Loading...