defparam cumulateorders=false
// --- settings
ATR = 82 //daily ATR value
myTarget = 1.3 //target profit coefficient
Capital = 5000 //capital at starting of the strategy
Risk = 1 //risk in %
StartTime = 080000
EndTime = 163000
// --- end of settings
//indis
bollm = ExponentialAverage[20](open)
bollup = ExponentialAverage[20](open)+2*std[20](open)
bolldn = ExponentialAverage[20](open)-2*std[20](open)
tcondition = (time>=StartTime and time<=EndTime) and (opendayofweek>=1 and opendayofweek<=5)
if tcondition then
//short orders
if high-bollm>ATR*0.25 and low>bollup and high-close > close-open then
//money managenemt
sellentry = low-1*pointsize
sellstoploss = high+1*pointsize
StopLoss = sellstoploss-sellentry
selltarget = StopLoss*myTarget
equity = Capital + StrategyProfit
maxrisk = round(equity*(Risk/100))
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
//pending order
sellshort PositionSize contract at sellentry stop
set target profit selltarget
set stop loss StopLoss
endif
//long orders
if bollm-low>ATR*0.25 and high<bolldn and close-low > high-close then
//money managenemt
buyentry = high+1*pointsize
buystoploss = low-1*pointsize
StopLoss = buyentry-buystoploss
buytarget = StopLoss*myTarget
equity = Capital + StrategyProfit
maxrisk = round(equity*(Risk/100))
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
//pending order
buy PositionSize contract at buyentry stop
set target profit buytarget
set stop loss StopLoss
endif
endif
//graph high-ema20>ATR*0.2 and low>bollup