// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time.
DEFPARAM FLATBEFORE = 090000
// Cancel all pending orders and close all positions at the "FLATAFTER" time
DEFPARAM FLATAFTER = 173000
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
buytime = t*10000 + (M1*100)
selltime = (buytime + (M2*100)) //Not ok! The system don´t sell at the assigned time
//selltime = buytime + 500 //Not ok! The system don´t sell at the assigned time
//selltime = 160000 //OK! The system sell at the assigned time
// Conditions to enter long positions
//Check trend in 1day chart
timeframe(1 day, updateonclose)
ma = average[70]
longtrend1 = close > ma
//Set time frame to default
timeframe(default)
indicator1 = adx[14]
momentum1 = indicator1 > mom and indicator1 < mom1
IF longtrend1 AND momentum1 AND not daysForbiddenEntry THEN
if time=buytime then
BUY 1 CONTRACT AT MARKET
ENDIF
endif
// Stops and targets
SET STOP %LOSS 0.15
// Conditions to exit long positions
IF longonmarket then
if time=selltime THEN
sell 1 CONTRACT AT MARKET
ENDIF
endif