I guess the big similarity is that we receive one initial signal (go long for example) and then increase the position size. We learn that not all trades up to the maximum position size must be taken since some strategy-indicator combinations will just not get to the point of entering the market
It is exactly this that makes it quite difficult to backtest accurately. If you have a backtest bell curve and decide to enter at the top and two positions either side it is not always guaranteed that all five positions will open. You will also want to optimize again and if for example your first optimization says that a variable set at 1 2 3 4 and 5 straddles your bell curve and then a day or two later 3 4 5 6 and 7 straddle the bell curve then if you are still opening bets on 1 and 2 you are well off the mark with those bets – but just imagine if you were only allowed to place one bet and then you would find that it is still on 3 which used to be the best place but is now on the edge of being the worst place. For me this is why I feel that diversification of a key variable in a strategy is probably a benefit – an unproven theory thus far by myself but one worth continuing with I think.
Thanks for everyone’s input so far. I believe that discussions on the theory of position sizing, diversification and methodology are as important as finding that winning combination that gives a strategy an edge.
Since I don’t know if a picture of my notebook is really helpfull for anybody, here is a little guide and toolkit to test the method we are discussing. This way everybody can check for themselves.
We can backtest a different set of indicator values with PRT. Run a simple backtest with the respective range for the indicator value. Sort the results according to the indicator you are testing. Don’t close the result list! Prorealtime provides a reasonably good result table IMO.
Here is the position sizing function:
1
2
3
4
5
6
7
8
MAXSHARES=(COUNTOFLONGSHARES<=5)
IflongonmarketandCOUNTOFLONGSHARES<=MAXSHARESthen
Buy1contractatmarket
//Buy 5 contracts at market
Endif
Set stoplosspositionsize×X
Set targetpositionsize×X
Time dependent entry and exit variables can also be tested with adapting values.
In this example the system initiates the sequence of trades with a time lag:
This will help to calculate returns for a long term etf strategy buying regularly like Casper’s great piece. https://www.prorealcode.com/topic/vusa-daily-buy-and-hold-v2-0/
If we buy a real etf and not a cfd on a etf the cost calculation is a lot more easy.
Another possibility is to wait for better prices before adding more positions:
Maybe somebody else provides the code to withhold the first trade before the price drops. In the example above, at least we don’t miss any big move completely. A more classic trendfollowing approach is waiting for the price to actually go up first. I added the example because it’s also included in the book chapter mentioned in my last post.
Of course a time based exit with adapting values can also be implemented. For every new trade, the exit is delayed.
1
2
3
IfonmarketandBARINDEX-TRADEINDEX(1)>=Xthen
Sellatmarket
Endif
As usual more complex functions can be applied to change the indicator values. This way we can test different distributions other than linearity. In the examples above X marks the indicator which is tested. An example for an exponential distribution:
1
X=round(exp(indicatorvalue)-1)×100//the round can be excluded if not needed
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue