// 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 = 075000
// Cancel all pending orders and close all positions at the "FLATAFTER" time
DEFPARAM FLATAFTER = 235500
// Prevents the system from creating new orders to enter the market or increase position size before the specified time
noEntryBeforeTime = 075000
timeEnterBefore = time >= noEntryBeforeTime
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime = 150000
timeEnterAfter = time < noEntryAfterTime
// 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 CROSSES OVER 35)
IF c1 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
BUY 13 PERPOINT AT MARKET
ENDIF
// Conditions to exit long positions
indicator2 = RSI[14](close)
c2 = (indicator2 CROSSES OVER 70)
IF c2 THEN
SELL AT MARKET
ENDIF
If not OnMarket then
// Do your Buy or Sell thing.
Endif
// or :
If not LongOnMarket then
// Do your Buy thing.
Endif
// or :
If ShortOnMarket then
// Do your Exit Short thing.
Endif
// Conditions to enter short positions
indicator3 = RSI[14](close)
c3 = (indicator3 CROSSES OVER 60)
IF c3 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
SELLSHORT 13 PERPOINT AT MARKET
ENDIF
// Conditions to exit short positions
indicator4 = RSI[14](close)
c4 = (indicator4 CROSSES UNDER 30)
IF c4 THEN
EXITSHORT AT MARKET
ENDIF
If not OnMarket then
// Do your Buy or Sell thing.
Endif
// or :
If not LongOnMarket then
// Do your Buy thing.
Endif
// or :
If ShortOnMarket then
// Do your Exit Short thing.
Endif
// Stops and targets
SET STOP pLOSS 1 pTRAILING 60
SET TARGET pPROFIT 150