DEFPARAM CumulateOrders = TRUE
// Prevents the system from creating new orders to enter the market or increase position size before the specified time
noEntryBeforeTime = 083000
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
timeframe(1 hour, UPDATEONCLOSE)
Atr = AverageTrueRange[14](close)
PerC = Atr * 100 / close
Atr1 = AverageTrueRange[14](close)
PerC1 = Atr * 100 / close
Change = ABS(close - close[10])
calc = ABS(close-close[1])
volat = summation[10](calc)
ER = Change / volat
vol1 = perc1 < v1
vol2 = perc > v2
noiseok = er > v3
Change = ABS(close - close[10])
calc = ABS(close-close[1])
volat = summation[10](calc)
km = Change / volat
trend1 = close > km
trend2 = close < km
timeframe(10 minute, default)
bearEngulf=(close[1] > open[1] and open > close and open >= close[1] and open[1] >= close and open - close > close[1] - open[1] )
startBreakeven = AverageTrueRange[14](close)*sb
PointsToKeep = AverageTrueRange[14](close)*pk
//reset the breakevenLevel when no trade are on market
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF
//short entry
if bearEngulf and trend1 and vol1 and vol2 and noiseok AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry then
sellshort 1 contract at market
endif
IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice(1)-PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel>0 THEN
EXITSHORT AT breakevenLevel STOP
ENDIF