How can I debug my trading strategies in Wealth-Lab?
by Dion Kurczek
NOTE: Visual Studio 2012 Express includes "Attach to Process" feature, so the workaround described below is no longer actual. You may continue using it with previous versions of Visual Studio Express such as VS 2010 Express.
The benefit of Visual Studio 2005/2008 Express Editions
(namely C# and VB .NET) and SharpDevelop 3.2
is that they're available for free. However, both these products lack an attach-to-process debugging ability helpful to debug a DLL. *
At least SharpDevelop allows to specify startup behavior for the project -- and we're going to employ it. Unfortunately, this feature is not present in the project's Debug tab in Express Editions, still there's a simple workaround at hand. In the following paragraphs we will show the steps required to debug your Strategy using the freeware IDEs.Note:
we will be referring to step numbers of the original article by Dion Kurczek, so please keep it open for your reference.Note!
You need to select .NET 2.0
as the target framework of your solution in its properties, otherwise you won't see the strategy in Wealth-Lab's "Open Strategy" dialog.
SharpDevelop 3.x, 4.x and above
Starting with 3.x branch, SharpDevelop received the native ability to attach to process for its built-in Debugger, greatly simplifying the debugging process. Refer to the Dion Kurczek article
for the procedure is basically the same, except for some dialogue and menu item titles.
However, debugging compared to Visual Studio (even Express) is pretty limited: debugging 64-bit (x64) processes and "Edit and Continue" are not supported. Both shortcomings are expected to get resolved in the 5.x branch.
This part has become obsolete with the release of SharpDevelop 3.x.
With an exception of step #7 which is not applicable, working with SharpDevelop follows the same concepts. Notice the following differences:
Step #5: In SharpDevelop, the code completion feature is invoked by keyboard shortcut Alt-Insert
Step #6: Insert a new Guid using the Edit/Insert/Insert new GUID
menu item or by pressing Ctrl-Shift-G
After you have successfully completed steps 1 to 9 of this tutorial, an extra step is required to change the project's startup behavior. In "Start Action" tab (Project - Project options), choose "Start external program", navigate to Wealth-Lab Pro (Developer) 6 installation folder and select WealthLabPro.exe (WealthLabDev.exe):
C:\Program Files\Fidelity Investments\Wealth-Lab Pro 6\WealthLabPro.exe
C:\Program Files\MS123\Wealth-Lab Developer 6\WealthLabDev.exe
Here's what you will need to do instead of steps #12 and #13 above:
#12. When you click "Debug" (F5) next time, WLP5 will start automatically. Move on to opening your Precompiled Strategy Library (step #14) or, to avoid duplicate actions, save your layout as the Default Workspace in WL5. In that case, go right to step #16.
When debugging the library is finished, you may roll back the change by deleting the Default Workspace file:
"c:\Documents and Settings\[YOUR_USER_NAME]\Application Data\Fidelity Investments\WealthLabPro\184.108.40.206\Data\Workspaces\Default.ws"
(for Wealth-Lab Developer 6:
"c:\Documents and Settings\[YOUR_USER_NAME]\Application Data\Fidelity Investments\WealthLabDev\220.127.116.11\Data\Workspaces\Default.ws"
#13. (n/a). Skip it.
Visual Studio 2005/2008/2010 Express Editions (C# and VB .NET)
For example, the action sequence for VS C# 2005 Express Edition will look like this:
Suppose your project file name is "TestLibrary
.csproj". Create a file "TestLibrary
" and put it to the very same directory where "TestLibrary
.csproj" is. (In other words, name it after your project file and append an extra extension .user
). Then, open up the new file in Notepad or any other text editor, paste the following XML code and save the file:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<StartProgram>c:\Program Files\Fidelity Investments\Wealth-Lab Pro 6\WealthLabPro.exe</StartProgram>
For Wealth-Lab Developer 6, substitute the text in bold with the following one:
c:\Program Files\MS123\Wealth-Lab Developer 6\WealthLabDev.exe
With this workaround, the Express Edition is basically instructed to launch Wealth-Lab Pro 6 when we start debugging (F5). It will be more convenient to take an extra step and prepare the Default Workspace (explained above). As with SharpDevelop, either continue to step #14 (because attach-to-process debugging is absent) or, if you prepared the Default Workspace with your test library, go right to step #16 (when debugging is finished, you may roll back the change by deleting the Default Workspace file as well.)
Note for Visual Basic .NET Users
In short, here's what Visual Basic .NET should do:
1. Create a VB project for your class library.
2. Include required References to WealthLab.dll, WealthLab.Indicators.dll etc.
3. Create a class for your Strategy e.g. MyStrategy that implements WealthScript
4. Create another class adding Helper to the StrategyName i.e. MyStrategyHelper
Public Class MyStrategy
Protected Overrides Sub Execute()
Public Class MyStrategyHelper
5. Right-click on the interface name and let Visual Studio generate all skeleton code for interface members.
Public Class MyStrategyHelper
Public Overrides ReadOnly Property Author() As String
Public Overrides ReadOnly Property CreationDate() As DateTime
Return New DateTime(2008, 7, 19)
Public Overrides ReadOnly Property WealthScriptType() As Type
6. Code your Strategy and debug as explained in this article for C# programmers.
Note on creating a Guid for your Strategy in Visual Studio Express Editions
: the GUID of each
Strategy in your class library should be unique
Both generation of Visual Studio Express lack "Create New Guid" functionality. For strategy developer convenience, we've built a tiny utility that generates a new Guid string and copies it to clipboard ready to insert in Strategy code.
Follow the steps below to integrate the tool into your Express Edition:
1. Configure CreateGuid.exe as an External Tool
2. A new menu item: "Create New Guid"
CreateGuid VS C# 2008 Express project
3. CreateGuid window