defparam cumulateorders = false
REM Money Management
Capital = 2500 // initial capital at launch of the strategy
Risk = 3 // risk in percent
REM Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*(Risk/100))
REM defining moving averages
EMA5 = exponentialaverage[5]
EMA100 = exponentialaverage[100]
EMA200 = exponentialaverage[200]
hh = highest[20](high)
ll = lowest[20](low)
// -- case BUY
if EMA5 crosses over EMA200 then
stoploss = (close-ll)/pointsize
stoplevel = (close-ll)
If stoploss < 15 then
stoploss = 15
Endif
if (time >=090000 and time < 210000) then
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
BUY PositionSize SHARES AT MARKET
endif
endif
// -- case SELL
if EMA5 crosses under EMA200 then
stoploss = (hh-close)/pointsize
stoplevel = (hh-close)
If stoploss < 15 then
stoploss = 15
Endif
if (time >=090000 and time < 210000) then
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
SELLSHORT PositionSize SHARES AT MARKET
endif
endif
// -- trades exit
if EMA5 crosses under EMA100 then
SELL AT MARKET
endif
if EMA5 crosses over EMA100 then
EXITSHORT AT MARKET
endif
SET STOP LOSS stoplevel