Speaking about volatility and position sizing I usually just take:
atr = averageTrueRange[20](Close)
positionsize = account / (atr)
and make some number up in account to fit that particular market. Anyone else have some nice algorithm for position sizing for volatility?
This one I almost always use:
ONCE nLots = 1
ONCE LotManagement = 0 //1=enable LOT size management
ONCE NeverDecrease = 1 //1=do not decrease lot size when losing,
// 0=decrease lot size according to strategyprofit
ONCE MinLots = 1 //1 Min lots allowed
ONCE MaxLots = 99 //99 Max lots allowed
ONCE MyDrawDown = 200 //200 DrawDown as from backtest
ONCE MyMargin = 70 //70 Margin required
ONCE DD = 3 //3 DrawDown multiplier
Capital = (MyMargin + (MyDrawDown * DD)) * nLots
Equity = Capital + StrategyProfit
IF LotManagement = 1 AND BarIndex > 0 THEN
nLots = max(MinLots,min(MaxLots,Equity / Capital))
IF NeverDecrease = 1 THEN
nLots = max(nLots,nLots[1])
ENDIF
ENDIF
- Line 1: Number of lots (default)
- Line 2: 1=lot management enabled, 0=disabled
- Line 3: 1=do not decrease after a loss, 0=decrease the number of lots after a loss
- line 5: Minimum lots allowed (can be < 1, if allowed by your broker)
- line 6: Maximum lots allowed
- line 7: DrawDown show by backtest
- line 8: Margin required by the broker
- line 9: DrawDown Multiplier (3 is the value I use by default)
You should start with line 2 se to 0 (lot management disabled), until you have finished optimizing, then write the correct value at lines 7 and 8 and backtest it again to save it and see the results.
You should backtest using a CAPITAL that is exactly (rounded) the one calculated at line 10 (nLots used here is the initial lot size set at line 1).
nLots is the number of lots you want to BUY/SELLAHORT.