The goal is to be able to optimize on a multiplier (y) of ATR(14) for position sizing.
1)
Each trade is x% of portfolio value, each position is adjusted by a multiple which is nothing more than:
(stock price - (y*ATR(14)))/stock price
//([price] - [recent volatiiity]) / [price] = volatility_adjusted_multiple
2)
Where should this live?
CODE:
Please log in to see this code.
Thus the more volatile a stocks price, the lower my multiple for position sizing.
Thanks,
Hank
Size:
Color:
Size:
Color:
Thanks Eugene, I read that. I have been reading the results of searching for an answer for weeks on volatility and ATR position sizing.
If I can do the above, it is the cleanest, simplest approach that I've found.
For instance, I want to just use something like:
PositionSize = (plug in formula as above)
Which allows me to take care of what I need without the posSizer.
Hank
Size:
Color:
Without the PosSizer, you'll not be able to optimize position size. This is the message in the FAQ. Hope this is clear.
What you can do in Strategy is to attempt prioritize the signals in a situation where multiple trade alerts compete for limited capital. Since the trades are executed in order of Position.Priority, you can assign a negative sign to your lowest volatility stocks so they'd take precedence.
After turning the wizard's redundant output into something terse and manageable and inserting the priorty code we have the following. Note! The code isn't ready yet -- you need to substitute your value for the "volatility_adjusted_multiple" to make it work:
CODE:
Please log in to see this code.
Size:
Color:
Problem, when I put my calculation in that line,
CODE:
Please log in to see this code.
I receive the error "Cannot implicitly convert type "'WealthLab.DataSeries
to 'double'
I tried using the ATR.Value(Bar, Bars, 14) to no avail - I get the same error
Size:
Color:
CODE:
Please log in to see this code.
Syntax error; see DataSeries >
Accessing a Single Value from a DataSeries in the WealthScript Programming Guide.
Size:
Color:
I have resolved this by creating a custom data series for the volatility adjustment.
CODE:
Please log in to see this code.
and later...
CODE:
Please log in to see this code.
By the way, if I include a multiplier attached to that data series for optimization, I get the same results no mater what the multiplier is.
That multiplier for optimization would mean a slight change as:
In the Public MyStrategy() section
CODE:
Please log in to see this code.
And an initialization
CODE:
Please log in to see this code.
and a change to the dataseries
CODE:
Please log in to see this code.
Except for not understanding why I can't optimize this variable, I'm all set. I'll find the FAQ you mentioned earlier.
Thanks for your help Eugene,
Hank
Size:
Color:
There's logic error i.e. conflict between the Strap accepting floating point values (increment = 0.2) and initializing the VolMult as ".ValueInt". Either use .Value or choose a different (integer) step for the Strap.
Size:
Color:
Eugene,
Would you please point me to the FAQ? I'm having mental anquish on why I can't access current cash balance, multiply that time 2%, find the volatility of the stock in question, reduce my 2% by that volatility and then purchase resulting value/price per share = number of shares.
Maybe I was reading the wrong FAQ? The opening line in the one linked above is just DEAD WRONG:
Position sizing based on volatility suggests to keep a wider stop when the market has a higher volatility while preserving your maximum per trade loss, effectively instructing to buy less shares during volatile periods, and more shares during calmer periods. If you want constant risk, then in current version you could determine the stop based on volatility (for instance, as a multple of the ATR unit), pass it as RiskStopLevel before taking the Position, and use Max Percent Risk sizing.
-----------
Position sizing means taking a smaller than normal trade size when entering the market on higher volatility. That statement is in reference to volatility stops.
Constant risk would be that one always enters the market in the same percent of equity or dollar value.
I want to implement money management first, then volatility adjusted sizing second. We haven't even place a trade yet and should not be addressing stops.
Thanks,
Hank
Size:
Color:
QUOTE:
The opening line in the one linked above is just DEAD WRONG:
Probably the only thing wrong is to think otherwise than written in the FAQ. Keeping tight stops when the market is volatile - this is wrong in my book. The percent-volatility PosSizer adjusts the trade size, reducing it during high volatility times and vice versa, while you can keep a reasonably wider stop and do not overexpose yourself to increased risk.
QUOTE:
why I can't access current cash balance, multiply that time 2%,
Because in Wealth-Lab, 1) position sizing is applied
after a Strategy has finished executing, and consequently, 2) it can not and does not provide Strategies with the cash and/or equity DataSeries. (There's a workaround:
Interacting Dynamically with Portfolio Level Equity which appears to be not too precise/robust so I'm not suggesting it.)
To close the question: optimizing a position sizing from a Strategy, if you followed the FAQ suggested in my first reply, takes just a little extra step
if it's your own PosSizer (i.e. you developed it and own the source code):
QUOTE:
However, you can pass on the optimizable value(s) from your Strategy to your custom PosSizer using the Position.Tag property.
P.S. That won't work with already available PosSizers though. Good news: there's an exception and it's called
Position OptionsA recently introduced option called "Use .Tag" allows to define the Percent-Equity or Max % Risk input programmatically, opening the door to optimize position sizing out of the box. However, without access to cash/equity DataSeries from a Strategy I'm not sure how helpful could that be so please treat my
P.S. "on a related note" only.
Size:
Color:
I understand your point on volatility based stops.
That FAQ is just not worded properly, mostly due to the incorrect start up: "Position sizing based on volatility suggests to keep a wider stop" - that is the portion which is dead wrong. Volatility based position sizing is exactly as I have stated - it has nothing to do with stops. That's not an arguable point.
It should read something like: Volatility should be a consideration for both position sizing and determining stops. During times of higher volatility, a measure of volatility should be used to both reduce the value of current risk employed and to modify stops to wider ranges in order to accommodate market conditions.
I've read about the volatility pos sizer, can you help me a bit?
In the configuration, what is percent volatility? Should this actually state "percent of ATR to use as volatility measure"? Thus if I want to use 3 times ATR I would enter 300?
The next, ATR Period - clear - I wish to use a multiple of x days ATR as we were discussing at the beginning of my thread.
Cap position at X% of account equity, is this per entry, or per symbol? If I have a pyramiding buy going on, is that the % of equity per trade or the % of equity for all trades in a security?
Thanks Eugene.
Hank
ps. I've been reading about passing of values via .tag - not clear on what values can be passed.
Size:
Color:
QUOTE:
I've read about the volatility pos sizer, can you help me a bit?
The formula for percent-volatility position sizing is:
Position size = (Current Equity * %Volatility) / (X-period ATR * point value)
where:
* %Volatility = is the percentage of current equity to risk per trade
* Point value is 1 per share for stocks.
QUOTE:
ps. I've been reading about passing of values via .tag - not clear on what values can be passed.
Possible value types are unambiguously indicated
in the online usage guide.
Size:
Color:
The value for % volatility in this case is represented by a whole number rather than a decimal? Thus 2 percent is 2.000 rather than .020?
If % volatility is the perecentage of current equity to risk per trade, then the next option "Cap position at X% of account equity" allows me to put a maxium % of equity for all trades in a symbol (1 or more trades making a "position")?
I wish to use a multiple of X-period ATR; currently impossible?
The "Use .Tag" option allows the setting of share size in the code passed to PosSizer - I see your point as without access to current equity value, I wouldn't know what size to use.
What's not clear in the PosSizer settings shown in that link that you have given are the values to use in order to ignore any of the options. For instance, if I don't wish to cap "Max pos. per day" do I set it to 0 or 9999?
Thanks for the help!
Size:
Color:
QUOTE:
The value for % volatility in this case is represented by a whole number rather than a decimal? Thus 2 percent is 2.000 rather than .020?
Yes, of course. 2 percent is 2%, not 0.02. Usually, figures above 1% can be considered pretty risky and cause skipping a lot of trades due to a high average position size.
QUOTE:
the next option "Cap position at X% of account equity"
The option simply is a position size limit. The position size will never exceed the user-specified figure (e.g. 10%) even the percent-volatility formula determined the size of the next trade as e.g. 60%.
QUOTE:
I wish to use a multiple of X-period ATR; currently impossible?
A multiple of ATR reduces the size respectively, isn't it? Will scaling the percentage down proportionally do the job?
QUOTE:
For instance, if I don't wish to cap "Max pos. per day" do I set it to 0 or 9999?
If you don't wish to cap something, then simply do not press that button. If it's depressed, click to disengage. The value is remembered to avoid constant typing in but the option becomes inactive. Simple?
Size:
Color:
Scaling percentage of each trade through a percentage of:
(price - X * ATR(14)) / price
will reduce the trade size more during times of high volatility - the goal!
I used PosSizer with volatility of 2.000 and "cap position at 2.000"
The result was that the system made multiple buy/short decisions in which an individual entry was always below 2% of account equity. I have not summed the total value of trades active at one time within a symbol to find what my exposure per symbol is yet.
Is the definition of a position in Wealth-Lab the industry standard of: the net of multiple trades in a given security? Sometimes it seem that position is actually trade size.
Size:
Color:
Position is actually trade size.
This has been the design for (almost) ten years. Wealth-Lab is Position based. No industry standards, no "net position", no cash position, no adding to position, no deleveraging. Each trade creates a Position object - including partial exits via SplitPosition that simply create one more Position and exit it.
Size:
Color:
Ah, to industry types, one would describe Wealth-Lab as trade based, not position based.
It's been a bit confusing, but thinking in Wealth-Lab speak should help me! I've previously worked on and with institutional order management and trade execution systems and was having issues with the position concept within Wealth-Lab.
Thanks for the help Eugene.
Size:
Color: