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