// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
//
Reinvest=1
if reinvest then
//Capital = 10000
Capital = 1000
//Risk = 1//in % pr position
Risk = 10//0.1//in % pr position
StopLoss = 50
//StopLoss = 70
REM Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*(Risk/100))
MAXpositionsize=1000
//MINpositionsize=1
MINpositionsize=1
Positionsize= MAX(MINpositionsize,MIN(MAXpositionsize,abs(round((maxrisk/StopLoss)))))//*Pointsize))))
else
Positionsize=1
StopLoss = 50
//StopLoss = 70
Endif
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// Conditions to enter long positions
indicator1 = RSI[14](close)
c1 = (indicator1 < 20)
IF c1 AND not daysForbiddenEntry THEN
BUY Positionsize perpoint AT MARKET
ENDIF
// Conditions to exit long positions
indicator2 = RSI[14](close)
c2 = (indicator2 > 60)
IF c2 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator3 = RSI[14](close)
c3 = (indicator3 > 75)
IF c3 AND not daysForbiddenEntry THEN
SELLSHORT Positionsize PERPOINT AT MARKET
ENDIF
// Conditions to exit short positions
indicator4 = RSI[14](close)
c4 = (indicator4 < 40)
IF c4 THEN
EXITSHORT AT MARKET
ENDIF