// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM Preloadbars = 10000
// Prevents the system from creating new orders to enter the market or increase position size before the specified time
noEntryBeforeTime = 150000
timeEnterBefore = time >= noEntryBeforeTime
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime = 230000
timeEnterAfter = time < noEntryAfterTime
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
timeframe(4 hours,updateonclose)
MA200 = average[200]
MA50 = average [50]
bulltrend = MA200 < MA50
//"default" timeframe (the timeframe you will launch the strategy on)
timeframe(default)
// Conditions to enter long positions
indicator1 = RSI[9](close)
c1 = (indicator1 < 33)
indicator2 = Stochastic[14,3](close)
c2 = (indicator2 < 20)
indicator3 = Average[3000](close)
indicator4 = Average[750](close)
c3 = (indicator3 <= indicator4)
indicator5 = Average[250](close)
indicator6 = Average[3000](close)
c4 = (indicator5 > indicator6)
IF (c1 AND c2 AND c3 AND c4 ) AND bulltrend AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
indicator7 = RSI[9](close)
c6 = (indicator7 >= 79)
indicator8 = Stochastic[14,3](close)
c7 = (indicator8 >= 80)
indicator9 = Stochastic[14,3](close)
indicator10 = Average[4](Stochastic[14,3](close))
c8 = (indicator9 > indicator10)
IF c6 AND c7 AND c8 THEN
SELL AT MARKET
ENDIF
// Stops and targets
SET STOP pLOSS 60