// 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 = 211800
// Prevents the system from creating new orders to enter the market or increase position size before the specified time
noEntryBeforeTime = 090000
timeEnterBefore = time >= noEntryBeforeTime
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime = 170000
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//
//Pivots//
Pivot = (DHigh(1) + DLow(1) + DClose(1))/3
Sup1=2*((DHigh(1) + DLow(1) + DClose(1))/3) - DHigh(1)
Res1 = 2*((DHigh(1) + DLow(1) + DClose(1))/3) - DLow(1)
Res2= Pivot + (Res1-sup1)
//Sup2= Pivot - (Res1-sup1)//
//Conditions for enter long//
c1= Average[1](close) CROSSES OVER pivot
c2= Average[1](close) CROSSES OVER Res1
IF (c1) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
BUY 1 SHARES AT MARKET
ENDIF
IF (c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
BUY 1 SHARES AT MARKET
ENDIF
// Conditions to exit long positions//
el1 = high>Res1-3
IF longonmarket and el1 THEN
Sell 1 shares at market
ENDIF
el2 = high>Res2-3
IF longonmarket and el2 THEN
Sell 1 shares at market
ENDIF
SET STOP pLOSS 8