MarkParticipant
Senior
Hi,
I have been studying the concept of the Renko system,
I am interested in adopting this system but with money management/position sizing incorporated into it. Is this something that can be achievable with this type of system? I am trying to add it but struggling to code the position sizing.
Mark
Position sizing/money management can be incorporated into any automated trading strategies you’ll find into the Library. The lot sizing is only a variable that adjust dynamically to your profit and loss with its own calculation.
I believe you are talking about this renko trading strategy: http://www.prorealcode.com/prorealtime-trading-strategies/renko-automated-trading-with-moving-average-on-candlesticks-chart/
So please find below the modified code with the money management position sizing:
defparam cumulateorders = false
REM Money Management
Capital = 10000
Risk = 0.01
StopLoss = 10 // Could be our variable X
REM Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*Risk)
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
bsize = 20 //renko size in points
mmperiod = 20 //moving average period
orderstime = 300 //minimum seconds between 2 orders
boxsize = bsize*pipsize
once topprice = close
once bottomprice = close - boxsize*pipsize*2
if(close > topprice + boxsize*2) THEN
topprice = close
bottomprice = topprice - boxsize*2
barclose=topprice
ELSIF (close < bottomprice - boxsize*2) THEN
bottomprice = close
topprice = bottomprice + boxsize*2
barclose = bottomprice
ELSE
topprice = topprice
bottomprice = bottomprice
ENDIF
mm = average[mmperiod](barclose)
if barclose=barclose[1] then
mmRENKO = mmRENKO[1]
else
mmRENKO = mm
endif
if barclose crosses over mmRENKO AND ABS(time-lasttime)>orderstime then
BUY PositionSize SHARES AT MARKET
EXITSHORT AT MARKET
lasttime=time
endif
if barclose crosses under mmRENKO AND ABS(time-lasttime)>orderstime then
SELLSHORT PositionSize SHARES AT MARKET
SELL AT MARKET
lasttime=time
endif
Not tested, but should work as intend. Please give feedback.
MarkParticipant
Senior
Hi Nicolas,
This works for me, thank you