Buy at certain time of day (i.e. last five minutes)

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

    Hi, I’m very new to all of this so please excuse me =) I’m trying to write something where a buy order is executed if the price is 1/above MA200 and 2)in the bottom 10% of the days range. The problem though is that the buy gets executed the next day. I’ve set the system to be disabled all day except between 172000 and 172500 and I’m on a five minute chart.  Here’s where I’m at so far, any help would be greatly appreciated.

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated

    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 172000
    timeEnterBefore = time >= noEntryBeforeTime // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 172500
    timeEnterAfter = time < noEntryAfterTime
    // Prevents the system from placing new orders on specified days of the week

    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0

    // Conditions to enter long positions
    c1 = (close <= ((high – low)*0.1)+low)
    indicator1 = Average[200](close)
    c2 = (close > indicator1)
    IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF

    #54984 quote
    robertogozzi
    Moderator
    Master

    > For clarity of messages on ProRealCode’s forums, please use the “<>” (insert PRT code) button in the message editor toolbar to separate the text of the code part! Thank you! <<

     

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 172000
    timeEnterBefore = time >= noEntryBeforeTime // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 172500
    timeEnterAfter = time < noEntryAfterTime
    // Prevents the system from placing new orders on specified days of the week
    
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    // Conditions to enter long positions
    c1 = (close <= ((high – low)*0.1)+low)
    indicator1 = Average[200](close)
    c2 = (close > indicator1)
    IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF

    I tested it on EurUsd 5min and it works! I think it entered the trade when conditions were true. The only issue could be the duration, 3000+ bars!

    Roberto

    x.jpg x.jpg
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Buy at certain time of day (i.e. last five minutes)


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/07/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...