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

Forums ProRealTime English forum ProOrder support Buy at certain time of day (i.e. last five minutes)

Viewing 2 posts - 1 through 2 (of 2 total)
  • #54983

    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

    > 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! <<

     

    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

Viewing 2 posts - 1 through 2 (of 2 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login