//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
Found this code. Cant figure out what to change to add 1 contract to every losing trade. If losing trade, add positionsize+1. Reset after x winning trades in a row
tries this one as well, but cant seem to get it to work…
ONCE positionSize = 1
IF StrategyProfit < StrategyProfit[1] THEN
positionSize = positionSize + 1
if StrategyProfit > StrategyProfit[1] THEN
positionSize = positionSize
endif
ENDIF
I think position sizing should be completely redesigned because as it is now it supports many ideas other than increasing positions after a loss.
Nevertheless I think that replacing line 35 with:
positionSize = positionSize + 1
and at the same time you should set to 0 the two variables at lines 12 and 13 could do.