PosSizers (position sizing)When I run a strategy in a Raw Profit mode, a warning message tells me that some trades were dropped because of insufficient funds. Why?
It is possible in Raw Profit mode when a) Fixed Dollar sizing is selected and
b) the selected position size is not enough to purchase even one share of the instrument. It can happen with with higher-priced instruments such as indices. Consider this example: your position size is $1,000 Fixed Dollar, and at the time of entry the security's price exceeds the position size e.g. is $1,100. There are two options: switch to Fixed Shares or increase the Fixed Dollar position size.How do I implement volatility position sizing?
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.
A simple and effective solution that requires no coding: the Percent Volatility
PosSizer. As an alternative, to 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.Having read about "Operational difference between the Strategy Monitor and Backtester" in the User Guide, I wonder if it's possible to use percent of capital position sizing in SM?
In live trading, you only need to determine what that % of Equity once per day when you enter your trades. That will be some cash value, like $9,587. For the S. Monitor, then, you use Raw Profit mode and enter that value for the dollar size. The next day, you recalculate the size based on your account's equity value and change the Raw Profit dollar size again, and so on.How do I limit the maximum number of positions across the portfolio?
You need a PosSizer that can limit the number of open positions across the portfolio: Position Options
.Is it possible to exit trades when portfolio drawdown reaches -X% (for example)??
No. PosSizers will not enter or exit trades, they can only affect the position size of the next trade, or reject it completely. Consequently, if you stop trading after reaching drawdown of some magnitude, with no positions there will be nothing to raise the equity curve back.How to size a Position based on a DataSeries value? How to limit the number of entered positions based on a DataSeries value?
The most straightforward way is to pass that value with the Position's Priority
or (better) Tag
properties. Check this forum thread
for some helpful code snippets.Is it possible to use PrintDebug in a PosSizer?
Just not the built-in PrintDebug. However, to use the Output
window of Visual Studio or SharpDevelop, you need to do the following:
- Hit Ctrl-W, O to open the Output window (VS 2008 shortcut; Ctrl-Alt-O in SharpDevelop).
- Call Trace.WriteLine in your PosSizer:
System.Diagnostics.Trace.WriteLine( whatever_you_wanted_to_send_to_PrintDebug );
Is it possible to optimize a PosSizer?
Directly, no. However, you can pass on the optimizable value(s) from your Strategy to your custom PosSizer using the Position.Tag
How to pass a value from Strategy to PosSizer for Alert sizing?Problem
You're using currentPos.Tag
to size positions in a PosSizer which works only if currentPos
is not null
i.e. not for Alerts. Solution
It's possible to assign any value to the Bars
object using the Tag
property when sizing for an Alert and read it back in your PosSizer:
if( bar == Bars.Count-1 ) )
Bars.Tag = some_double_value;
For a complete code snippet, refer to the Bars.Tag
example in the Wealth-Lab QuickRef.No programming required:
Starting from version 2011.11, the Position Options
PosSizer supports passing a double
value via Position.Tag
to easily backtest a strategy-driven, flexible percent-equity or Max % Risk approach.
Why checking for EntryBar/ExitBar in portfolio simulations may produce unexpected results in PosSizers and Performance Visualizers?Reason
: because the different historical DataSets aren't synchronized when backtesting.Solution
: check for the date with EntryDate/ExitDate rather than the bar number:
//if (Positions[n].EntryBar == bar + 1)
if(Positions[n].EntryDate == bars.Date[bar + 1].Date)Why accessing an EquityCurve(CashCurve) value in multi-symbol portfolio simulations may produce unexpected results in PosSizers and Performance Visualizers?Reason
: because the different historical DataSets aren't synchronized when backtesting.Solution
: in a multi-symbol backtest, it's advised to use the ConvertDateToBar
method of the EquityCurve
DataSeries to get a correct bar. For example, here's how to determine the equity curve value at the beginning of a month using ConvertDateToBar:
double MonthStartEquity = EquityCurve;
DateTime b = bars.Date[bar];
DateTime tmp = new DateTime(b.Year, b.Month, 1);
MonthStartEquity = EquityCurve[EquityCurve.ConvertDateToBar(tmp, false)];
ExtensionsI can't download an Extension: the site says Wealth-Lab extensions are available only to Wealth-Lab Version 6 customers.
Wealth-Lab Extensions are not available during free trials. Extensions are premium content available to our registered customers, for free. They are not a part of Wealth-Lab Developer/Pro (excluding those already shipped with the installation and available without downloading), they're free, and are not subject to "try before you buy". No downloadable extension is an inherent part of the application without which it would cease to function. I can't see any open source in the Wealth-Lab Wiki?
Open source project code is available to registered customers of Wealth-Lab Developer/Pro, for free, and can be downloaded by clicking on "Attachments" of a project's home page. WLD/WLP customers who can't see "Attachments" - please enter a new support ticket at wealth-lab.com
. Note: source code is not available to trial users.I have a library of compiled Strategies. When I open some of them, all are the same or not the one I picked.
If opening differently named Strategies result in opening the same Strategy, and/or not the one you want, this is a common symptom of one (or several) of your Strategies not having a unique GUID
. You should correct the code so that the GUID of each Strategy in your class library is unique. For more details, see this article
Extension installed in Wealth-Lab Developer doesn't show up after restarting application.
This can happen when you have both x86 and x64 versions of Wealth-Lab Developer installed on the same computer. Installing an Extension in x86 version (for example), closing it and starting x64 version makes believe the Extension is gone. Because their executable/DLL files are installed into separate locations, Extensions should be installed separately for x86 and x64 versions of Wealth-Lab Developer (note: some Extensions can be incompatible with x64 version).Data providers only:
another possible reason is missing Market Manager
- a required component of many data providers. To get it back, reinstall any provider using it from the Extensions
section - ASCII, for example - and restart Wealth-Lab.
I'm getting an "access denied" error while building my extension in Visual Studio or SharpDevelop.
If the error message reads like this, you have Windows Vista, 7 or greater and should start Visual Studio or SharpDevelop with admin privileges explicitly, by right-clicking the shortcut and selecting "Run as admin":
Error Unable to copy file "MyExtension.dll" to "..\Program Files\MS123\Wealth-Lab Developer 6\...". Access to the path is denied.
I created an indicator library, but it doesn't show up in Wealth-Lab 6
I compiled TASCIndicators from source files but having trouble installing it.Problem
- for an Indicator, you have correctly implemented the IndicatorHelper
- placed the resulting DLL in Wealth-Lab's main folder
- targeted the right framework version. To be recognized by Wealth-Lab 6.4, .NET 4.0 can be selected. For version 6.3 and earlier, libraries must be targeting .NET 2.0 or 3.5 (by default, Visual Studio 2010 targets .NET 4.0 which is incompatible with WL 6.3 - this can be changed in your project's properties, and it should be recompiled)
- the target CPU is set to Any (and not to e.g. 32 bit)
- restarted Wealth-Lab after placing the DLL(s), if it was running.
When trying to update TASCIndicators
(or any other open source Extension) to get some new functionality (e.g. an indicator), you are building the source into a DLL and replacing the old one, but Wealth-Lab's built-in compiler won't recognize the new indicator, producing an error message that looks as follows:
error CS1704 @ (0.0): An assembly with the same simple name "TASCIndicators, Version=220.127.116.11, Culture=neutral, PublicKeyToken=nul
In addition, if you were trying to update an Indicator Library, a common symptom is to see two
related Indicator groups (folders) in the Indicator List window.Solution
This is the result of copying the assembly (DLL) in a wrong way, for example:
- If the new file has a name different from the original library (e.g. you are copying TASCIndicators.dll as TASCIndicators1.dll to the Wealth-Lab main program directory.
- If you renamed the original file for backup purposes but preserved the .dll extension (e.g. you've copied the new file named TASCIndicators.dll, renaming the old file as TASCIndicators.Copy.dll).
In both cases, you've got two conflicting files named differently. When starting up, Wealth-Lab scans for DLLs in its main program folder and if an assembly was recognized as implementing a certain interface (e.g. an indicator library), it will be loaded without version check, and its file will be consequently locked up.
Backing up an existing library is a good idea, but you should do so by renaming it in a way that effectively hides it from Wealth-Lab -- a proper file name would be, for instance, TASCIndicators.dll.bak
A library compiled for .NET 4.0 doesn't show up in Wealth-Lab 6
Upgrade to Wealth-Lab 6.4 or higher. Versions before 6.4 could not consume assemblies compiled for .NET 4.0 framework (6.3 is limited to .NET 2.0/3.0/3.5 only).
Can not compile my library after installing Wealth-Lab 6.4. What's wrong?
Wealth-Lab 6.4+ requires that you select .NET 4.0 Framework in your solution's properties.
VisualizersOne of the Performance Visualizer tabs is missing.
Make sure the checkbox for the Visualizer is checked under Tools > Preferences > Performance Visualizers.
If using a saved workspace, then it's possible that the window that you saved with the Workspace was created when the Visualizer was not enabled. Open that workspace, close the window, open that Strategy again, and re-save the workspace.Is there any way to add a column to the Trades visualizer and write data to it?
To the built-in performance visualizer, no.
To your own custom performance visualizer, yes. For example you can download Community.Visualizers
demo source code and modify the PVTrades2
class that represents the Trades+
visualizer. In short, adding a column would take the following:
Why checking for EntryBar/ExitBar in portfolio simulations might fail In PosSizers and Performance Visualizers?
- Add a column to the ListView (by defining a ColumnHeader) of the control.
- Specify the type of data (i.e. double) for the purposes of sorting (notice ListViewSortManager in the PVTrades2 constructor).
- GenerateOutput is used for copying to clipboard, so you should skip this method for now.
- Now, in CreateVisualization method body you will need to calculate your performance metric and use AddSubItem to push it to the ListView.
Answered above (PosSizers
Data and Broker providers
You must be a verified Wealth-Lab Developer/Pro 6 customer to view this page. Free trial users can not access this content.
MiscellaneousIs it possible to calculate correlation?Is portfolio rebalancing possible?
Not directly, but here are a few pointers: forum thread
.Is there a way to suppress the chart title with the symbol name and the rectangular box around it?
To put it simply, you can hide it by opening the Preferences
dialog and setting the font size of the "Symbol & Co. Name" to 1.Is there a way to profile Wealth-Lab 6 Strategies i.e. measure application/script performance?
Yes. This procedure helps find code bottlenecks. Please refer to this discussion: Wealth-Lab strategy performance profilingIs it possible to do multi-currency backtests with Wealth-Lab?
Wealth-Lab is single-currency focused, but some pointers worth taking a look can be found in this discussion
.Is it possible to use Wealth-Lab for futures spread trading?
You might find some pointers here
.Before upgrading to v6.2 I used an older version, now am experiencing differences with same code working with AtStop/AtLimit orders?
In 6.2, there were changes made that prevent skipping otherwise valid AtStop/AtLimit orders taken at bar's extremes that could happen in preceding versions. By default, Wealth-Lab adjusts stop/limit trigger prices to a "tick" value for stocks as well as futures. The tick value depends on the Pricing Decimal Places (configured in Wealth-Lab's Preferences > Advanced Options
). Sometimes this adjustment may cause a stop/limit order to fail due to precision issues. Versions prior to 6.2 assumed a 2-decimal "tick value" for stocks which could cause skipped AtLimit/AtStop orders.
Version 6.2 and higher provides more precision because the tick value will now use the number of Pricing Decimal Places configured (Preferences dialog). For instance, the tick is 0.001 if you set the number of decimals to 3. To sum it up, if you enter 3 Pricing Decimal Places in 6.2, stocks will be displayed and traded at 3 decimals. To completely ignore tick value adjustments, use the new option (from 6.2) called "Turn off limit/stop order rounding entirely" (Preferences > Backtest Settings). By enabling this option, you tell Wealth-Lab not to adjust stop/limit prices to a stock's tick value, instead executing the orders at full decimal precision.Note:
a correct comparison between the backtests created in 6.2 and earlier versions requires the number of Pricing Decimal Places to be set at 2 in both versions of Wealth-Lab.