// code-parameter
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM FlatAfter = 210000
// window high/low calculation
StartTime = 090000
EndTime = 092000
// Spread
sp = 1
// money management
Capital = 36000
Risk = 0.01
equity = Capital + StrategyProfit
maxrisk = round(equity*Risk)
PositionSizeL = abs(round((maxrisk/StopLossL)/PointValue)*pipsize)
PositionSizeS = abs(round((maxrisk/StopLossS)/PointValue)*pipsize)
// calculate high/low
IF Time >= StartTime AND Time <= EndTime THEN
orh = HIGHEST[20](high)
orl = LOWEST[20](low)
ENDIF
// Count number of trades
TradeCounter = 0
// position management
// Long
IF Not ONMARKET AND close CROSSES OVER orh AND TradeCounter < 5 THEN
// long
IF (Time >= 90000 AND Time <= 150000) THEN
BUY PositionSizeL PERPOINT AT MARKET
StopLossL = abs(close - orl) + sp
set stop loss StopLossL
SET TARGET PROFIT 150 * pipsize
TradeCounter = TradeCounter + 1
ENDIF
ENDIF
// short
IF Not ONMARKET AND close CROSSES UNDER orl AND TradeCounter < 5 THEN
IF (Time >= 90000 AND Time <= 150000) THEN
SELLSHORT PositionSizeS PERPOINT AT MARKET
StopLossS = abs(close - orh) + sp
set stop loss StopLossS
SET TARGET PROFIT 150 * pipsize
TradeCounter = TradeCounter + 1
ENDIF
ENDIF