// Gold breakout
// 1 hour
// One order per day, from 06:30h. The system shuts-down at 21:00h
// Everyday highest and lowest position from 2100 to 0400
DEFPARAM CUMULATEORDERS = false
// OPERATIONAL TIME
DEFPARAM FLATBEFORE = 063000
DEFPARAM FLATAFTER = 210000
Operationaltime = TIME > 063000 AND TIME < 210000
// ONE TRADE PER DAY. It resets the variable each new day
IF INTRADAYBARINDEX = 0 THEN
alreadytraded = 0
ENDIF
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 1 OR OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// RANGE between 2100h to 0400h
IF TIME=040000 THEN
channelhigh = Highest[7](high)
channellow = Lowest[7](low)
ENDIF
// BREAKOUT Conditions
c1= close > channelhigh
c2= close < channellow
// LONG Positions-Opening
IF Operationaltime AND not daysForbiddenEntry and c1 AND alreadytraded = 0 THEN
BUY 10 CONTRACT AT MARKET
alreadytraded = 1
ENDIF
// SHORT Positions-Opening
IF Operationaltime AND not daysForbiddenEntry and c2 AND alreadytraded = 0 THEN
SELLSHORT 10 CONTRACT AT MARKET
alreadytraded = 1
ENDIF
// Stops and targets
SET STOP LOSS 2.3*pipsize
SET TARGET PROFIT 8.0*pipsize