//Money Management
MM = 1 // 0 - disable, 1 - enable
if MM = 0 then
positionsize = 1
ENDIF
if MM = 1 then
//Configuration ----
once maxSize = 4 //maximum lot size
once minSize = 1 //maximum lot size
once startingsize = 1 //starting lot size
once stepsize = 1 //lot step size to increase/decrease
once resetafterlost = 1 //reset to starting lot size when loss. 0 - disable, 1 - enable
once doublestepdown = 1 //double the stepsize for decrease when loss. 0 - disable, 1 - enable
once resetafterstrikewin = 2 //reset the lot size to starting size after n wins
//Configuration ----
once positionsize = startingsize
once wincount = 0
if strategyprofit <> strategyprofit[1] then
if positionperf(1)>0 then
if positionsize < maxSize then
positionsize = positionsize + stepsize
endif
wincount = wincount + 1
if wincount >= resetafterstrikewin then
positionsize = startingsize
wincount = 0
endif
else
if resetafterlost then
positionsize = startingsize
elsif doublestepdown then
positionsize = positionsize - stepsize * 2
else
positionsize = positionsize - stepsize
endif
wincount = 0
endif
endif
if positionsize < minSize then
positionsize = minSize
endif
ENDIF