// Prevents the system from placing new orders on specified days of the week
DEFPARAM cumulateOrders = FALSE // Cumulating positions
AA = period
// Breakout criteria
a = highest[AA](high[1])//Max
b = lowest[AA](low[1])//Min
ATR = AverageTrueRange[2](close)
// Conditions to enter long positions
indicator1 = Average[100](close)
c1 = (close > indicator1)
indicator2 = RSI[2](close)
c2 = (indicator2 > 70)
c3 = (close > a)
c4 = (close[1] > a)
c5 = (open > open[2])
IF not SHORTONMARKET AND (c1 AND c2 AND c3 AND c4 AND c5) THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to enter long positions #2
indicator5 = Average[100](close)
c6 = (close < indicator5)
indicator6 = RSI[2](close)
c7 = (indicator6 > 50)
c8 = (close > b)
c9 = (close[1] > b)
IF not SHORTONMARKET AND c6 AND c7 AND c8 AND c9 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
c10 = (close < a)
c11 = (close[1] > a)
c12 = (close[2] > a)
c13 = (high < a)
c14 = (high[1] > a)
IF c10 AND c11 AND c12 AND c13 AND c14 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator10 = Average[100](close)
c15 = (close > indicator10)
indicator11 = RSI[2](close)
c16 = (indicator11 < 50)
c17 = (close < a)
c18 = (close[1] < a)
IF not LONGONMARKET AND (c15 AND c16 AND c17 AND c18) THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
//Conditions to enter short positions #2
indicator14 = Average[100](close)
c19 = (close < indicator14)
indicator15 = RSI[2](close)
c20 = (indicator15 < 40)
c21 = (close < b)
c22 = (close[1] < b)
c23 = (open < open[2])
IF not SHORTONMARKET AND c19 AND c20 AND c21 AND c22 AND c23 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit short positions
c24 = (close > b)
c25 = (close[1] < b)
c26 = (low > b)
c27 = (low[1] < b)
c28 = (low[2] < b)
IF c24 AND c25 AND c26 AND c27 AND c28 THEN
EXITSHORT AT MARKET
ENDIF
If (indicator2 > 95) Then
Sell at market
ElsIf ((close > close[1] + ATR) or SHORTONMARKET) and indicator2 < 5 Then
Exitshort at market
EndIf