Risk Based Position sizing
Author: dirk01
Creation Date: 10/12/2008 6:01 AM
profile picture

dirk01

#1
I just tried to backtest a simple system I wrote with your rule function;

80 day breakout entry with 2 % trailing stop and 2 ATR initial Stop Loss. I tried to backtest with risk based position sizing but only got back this: "Strategy must set risk stop level in order to use risk based position sizing....how come? This should have been covered with my initial 2ATR stop????

Any help would be greatly appreciated!
profile picture

Eugene

#2
QUOTE:
"Strategy must set risk stop level in order to use risk based position sizing....how come?


Hit F11, expand the Trading category, see RiskStopLevel - it's explained there with an example.
profile picture

dirk01

#3
Thanks but doesn't my 2ATR Stop Loss qualify as Risk Stop Level?

profile picture

Eugene

#4
Yes it does, but to qualify as risk stop level the RiskStopLevel property should be properly assigned.
profile picture

dirk01

#5
Sorry but I have no idea what you're saying. Could you please explain in a little bit more detail?
profile picture

Cone

#6
First thing, make sure that you understand what Max Risk % Sizing is and how Positions are sized when using it. See User Guide: Reference > Data Panel > Position Size Control > Portfolio Simulation Mode, Max Percent Risk.

Second, hit F11 to open the QuickRef and look up RiskStopLevel, read, and try to understand the example.

Third, if you want to use Max Risk % sizing, you must tell Wealth-Lab what the RiskStopLevel is before you take the Position - otherwise, how do you know how much to buy (or short)?

Finally, just because your Strategy uses a stop, it doesn't imply that it's the the RiskStopLevel. A strategy can have many different stops. However, if you properly use Max Risk % sizing, one of those stops must be at the RiskStopLevel to guard against maximum % loss that you determined when you put on the position.

I sure hope this makes it clear!
profile picture

dirk01

#7
Thanks for your detailed explanation. I do understand the concept of % based position sizing and have used it in the markets over the last years. Example: I do have a $10,000 Portfolio and do not want to risk any more than 1% of Portfolio. This is $100. My trading plan uses an 2ATR trailing stop and the 1ATR of the share might be $2. Therefore I would be buying 25 shares.

Am I right that I can not set a RiskStop Level in form of a basic % based stop loss or ATR based trailing stop in your chart wizzard as they do not qualify as a RiskStopLevel? I suppose I would have to program the RiskStopLevel in code and it would look something like that
SetRiskStopLevel( PriceClose( Bar ) - 2ATR

Thanks again for all your help and patience :-)
profile picture

Eugene

#8
QUOTE:
Am I right that I can not set a RiskStop Level in form of a basic % based stop loss or ATR based trailing stop in your chart wizzard as they do not qualify as a RiskStopLevel?

True, risk stops are outside the scope of the rule wizard and therefore have to be coded manually e.g.
CODE:
Please log in to see this code.
profile picture

seventyfive

#9
QUOTE:
Thanks for your detailed explanation. I do understand the concept of % based position sizing and have used it in the markets over the last years. Example: I do have a $10,000 Portfolio and do not want to risk any more than 1% of Portfolio. This is $100. My trading plan uses an 2ATR trailing stop and the 1ATR of the share might be $2. Therefore I would be buying 25 shares.


I also do the same thing but I can't get wealth-lab to execute this properly. I am using 5.3 Pro. Here is my code, can anyone please tell me what I'm doing wrong. Wealth Lab buys a position equal to 2% of my equity instead of risking a 2% downside.

I will be honest, I can't code at all so I'm mostly guessing based on what Eugene gave as example code. If anyone can help I would greatly appreciate it. Thank you!

CODE:
Please log in to see this code.
profile picture

Eugene

#10
Try this and let us know if something goes wrong (untested):
CODE:
Please log in to see this code.

1. You need to start the trading loop at least 3 times the ATR period because the indicator is "unstable". Please see the WealthScript Programming Guide > Indicators > Stability of Indicators for the explanation.
2. RiskStopLevel would be different for long and short trades, and should be set prior to issuing the order.
profile picture

seventyfive

#11
Thank you so much!! Your code makes it very clear how to use the RiskStopLevel function. I greatly appreciate your prompt response. Thank you for helping me, this was the kick in the pants I needed to make me want to learn C# ;)
profile picture

Eugene

#12
You're welcome.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).