Debugging a Strategy with Visual Studio Express 2013
Author: WW
Creation Date: 8/3/2014 5:22 PM
profile picture

WW

#1
Hello,

Debugging a Strategy with Visual Studio Express 2013 or wealth lab 6.6.

In the past I used Win XP 32 bit and Wealth Lab Developer 5 32 bit Visual Studio Express 2008. Everything worked well an I could debug with visual studio.

Now I upgraded to Win 7 professional 64 bit and Wealth Lab Developer 6.6 64 bit and Visual Studio express 2013. I do it this way:

1. build a class library
2. project refer to wealth lab.dll and wealth lab indicators.dll
3. build a class helper
4. add “using wealth lab instructions”
5. build a new guid
6. Is .NET Framework 4.5 established?
7. output path is „Program Files\MS123\Wealth-Lab Developer 6\”
8. start Wealth Lab
9. visual studio Attach to prozess Wealth-Lab-Developer.exe
10. wealth lab open strategie; there is no special symbol
11. I didn’t forget to save. I already tried different ways for saving: save in project visual studio, save in wealth lab main folder 6. Unfurtunatly nothing worked.

Did I forget something or do the systemn doesn’t work with the 64 bit version?

The following must have been droped out with Visual Studio 2013. Is this the case?

QUOTE:
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.csproj.user" 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:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<StartAction>Program</StartAction>
<StartProgram>c:\Program Files\Fidelity Investments\Wealth-Lab Pro 6\WealthLabPro.exe</StartProgram>
</PropertyGroup>
</Project>

For Wealth-Lab Developer 6, substitute the text in bold with the following one: c:\Program Files\MS123\Wealth-Lab Developer 6\WealthLabDev.exe

profile picture

Eugene

#2
Hi,
QUOTE:
Unfurtunatly nothing worked.

I read your detailed log, not expecting to find the "it doesn't work" mystery in the end. So what didn't work exactly? Got a specific error message or something else?

QUOTE:
The following must have been droped out with Visual Studio 2013. Is this the case?

Well, yes, it isn't required any longer since Express users now have the Attach to Process debugging. However, this step won't hurt if you like to start WLD6 automatically by hitting F5 (assuming you've placed the built file ino the WLD6 main folder) and don't care about attaching to process.
profile picture

WW

#3
Hi Eugene,

this is a detail from the error massage that apears when I finish attach to prozess Wealth-Lab-Developer.exe. Unfortunately the massage is in german.

"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" geladen. Das Laden von Symbolen wurde übersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "C:\Program Files\MS123\Wealth-Lab Developer 6\MetaLib.dll" geladen. Das Laden von Symbolen wurde übersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "Microsoft.GeneratedCode" geladen.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "Microsoft.GeneratedCode" geladen.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization.Formatters.Soap\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.Serialization.Formatters.Soap.dll" geladen. Das Laden von Symbolen wurde übersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_de_b77a5c561934e089\mscorlib.resources.dll" geladen. Das Modul wurde ohne Symbole erstellt.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "Microsoft.GeneratedCode" geladen.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "Microsoft.GeneratedCode" geladen.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsFormsIntegration\v4.0_4.0.0.0__31bf3856ad364e35\WindowsFormsIntegration.dll" geladen. Das Laden von Symbolen wurde übersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms.resources\v4.0_4.0.0.0_de_b77a5c561934e089\System.Windows.Forms.resources.dll" geladen. Das Modul wurde ohne Symbole erstellt.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\UIAutomationTypes\v4.0_4.0.0.0__31bf3856ad364e35\UIAutomationTypes.dll" geladen. Das Laden von Symbolen wurde übersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "Microsoft.GeneratedCode" geladen.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero.dll" geladen. Das Laden von Symbolen wurde übersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.resources\v4.0_4.0.0.0_de_31bf3856ad364e35\PresentationFramework.resources.dll" geladen. Das Modul wurde ohne Symbole erstellt.
"WealthLabDev.exe" (CLR v4.0.30319: WealthLabDev.exe): "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\UIAutomationProvider\v4.0_4.0.0.0__31bf3856ad364e35\UIAutomationProvider.dll" geladen. Das Laden von Symbolen wurde übersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
Der Thread 0xe4c hat mit Code 259 (0x103) geendet.
Das Programm "[2636] WealthLabDev.exe" wurde mit Code 0 (0x0) beendet.
profile picture

Eugene

#4
1. Double check that your project is not targeting "x86" only on now 64-bit system.
2. Make sure that your PC clock is correct.

3. Also, do our our samples (as opposed to your solution) function correctly?
profile picture

WW

#5
Visual Studio is in the folder Programs (x86), it is 32 bit (Windows on Windows 64).Shall I install Visual Studio in programs where Wealth Lab is located? How should I go on?
profile picture

WW

#6
PC clock is correct
profile picture

Eugene

#7
I was not asking where VS is installed. The suggestion was to double check your build configuration which should be "AnyCPU" (not targeting "x86").

Also please see my question #3 above.
profile picture

mrsic

#8
Hi,

I am not a programmer but i do my best.
I am stuck at point 6 (How can I debug my trading strategies in Wealth-Lab?). How looks the content of a StrategyHelper?
For now it looks like this, See Attachment.


greetings damir.
profile picture

Eugene

#9
Hi,

Don't look any further:

Home - Strategies.ActiveTrader

This is a fully functional Strategy library with enough examples. Make sure you're logged in to the Wiki to see the green Attachments button on that page.
profile picture

mrsic

#10
Hi Eugene,

I used one of these samples but i am getting always the same message.
See Attachment. (only in german, sorry for that)

Debugging can't be started; an execute project is required.I dont know what to do, can you help me with them.

Thanks.

greetings damir
profile picture

Eugene

#11
Damir,

Since the example project is very old, it has to be adjusted to suit WLD 6.9 and .NET 4.5-4.7.

1. In Project Properties > Debug, make sure that "Start external program" is checked and it points at c:\Program Files\MS123\Wealth-Lab Developer 6\WealthLabDev.exe.
2. Also, all the References are also old and point at the WLD5 folder and have to be updated.
3. Finally, the project must be reconfigured to target .NET 4.5 or higher (it was created during .NET 2.0 times).

If you find something difficult, I've updated the project and uploaded it to the Wiki. Please simply delete your directory and download again.

P.S. If you have the ActiveTrader Strategy pack extension installed you will have problems. Uninstall it before compiling this project.
profile picture

mrsic

#12
Eugene,

@debug works but when i am starting the debug in my own strategy he says, Wealth Lab is always running!

@Active Trader Strategy 8 Errors. ".....\Wealth-Lab Developer 5' is denied."

NET 4.5.

Do i have something forgotten?


profile picture

Eugene

#13
Sorry, the project file contained one more reference to the WLD5 folder. Fixed now, please download again.
profile picture

mrsic

#14
Eugene,

until here is everythink okay. "no errors and warnings."
If i am starting the debug process in VS - Wealth lab automatically starts.I think this is normal (tutorial). But i can't see any breakpoints and F10, F11 is not in used. I can, stop, break or contnue the debugging process. What i am doing wrong?

greetings damir
profile picture

mrsic

#15
Eugene,

it works fine.

Thank you for your help.

Greetings Damir.
profile picture

Eugene

#16
Damir,

Glad you were able to set it all up.

Cheers.
profile picture

mrsic

#17
Hi,

i am updated VS on 2017. Active Strategy Trader works fine. But i can not find my precompiled Strategy in WL. Does anyone know what i am making wrong.

greetings
Damir
profile picture

Eugene

#18
Damir, I bet you've overlooked step #9 from this tutorial: How can I debug my trading strategies in Wealth-Lab?

QUOTE:
Set the Output Path of the project, in the Build tab of the Project's Properties, to the Wealth-Lab installation directory. This will cause the resulting assemblies to be built into the Wealth-Lab folder, and this be visible to Wealth-Lab. You must be running Visual Studio as administrator for this.


There can be other reasons (e.g. inappropriate bitness when both WLD x64 and x86 are installed, or incorrect .NET target framework) but this is the most standing out.

P.S. To avoid confusion you might want not to share class names (i.e. StochD) with the classes from Wealth-Lab's namespaces.
profile picture

mrsic

#19
Hi Eugene.,

i set the Output path: „Program Files\MS123\Wealth-Lab Developer 6\.

This is strange. Now i can not start WL! Should i WL reinstall?

P.S. WL works again but without precompiled Strategy.


profile picture

Eugene

#20
Using Visual Studio 2015 and 2017 for debugging, post #2

How can I debug my trading strategies in Wealth-Lab?, step #8

FAQ | Position Sizing, Extensions, Miscellaneous > "I successfully created a library of compiled Strategies but it crashes Wealth-Lab. Restart or reinstallation doesn't help."

If that doesn't help, give me something to work with. In the absence of any details (code, steps taken, WL/library 'bitness' etc.) all that's left is guesswork, and it's counterproductive.
profile picture

mrsic

#21
Hi Eugene,

thanks it works again. :-)

profile picture

Eugene

#22
Damir, it's a great feeling to have positive feedback like this.

P.S. Having noticed your 4 breakpoints, let me suggest this new way of stepping through your code offered by VS 2017:

Run To Click Debugging in Visual Studio 2017

I found this even more productive and fun compared to setting multiple breakpoints.
profile picture

mrsic

#23
Eugene thanks for the tip.
I will try out.
profile picture

Eugene

#24
Any time. The good thing about Run To Click is that it's more dynamic. Also note that breakpoints in VS have always been conditional i.e. can be based on an equation or number of hits.
profile picture

WW

#25
Hello,
I have a question again. My first posting is up-to-date. Debugging, breakpoints and so on are working. But I don't get an output. It doesn't matter wether I use "System.Console.WriteLine" , System.Console.Write... There is no error massage also. Can you help me?

Regards,
WW

create project :

1>------ Erstellen gestartet: Projekt: Testen, Konfiguration: Debug Any CPU ------
1> Testen -> C:\Program Files\MS123\Wealth-Lab Developer 6\Testen.dll
========== Erstellen: 1 erfolgreich, 0 fehlerhaft, 0 aktuell, 0 übersprungen ==========

CODE:
Please log in to see this code.



Output:

ConvertFromBars 1
ConvertToBars 5
ConvertBars: 21
Executing System
Der Thread 0x1e90 hat mit Code 259 (0x103) geendet.
Der Thread 0x2244 hat mit Code 259 (0x103) geendet.
Der Thread 0x1d4 hat mit Code 259 (0x103) geendet.
Der Thread 0x1ea8 hat mit Code 259 (0x103) geendet.
Der Thread 0x18dc hat mit Code 259 (0x103) geendet.
Der Thread 0xf4c hat mit Code 259 (0x103) geendet.


profile picture

superticker

#26
I'm assuming this operation is not for debugging; otherwise, you would be using the VS Debugger instead, which is much more powerful.

So Wealth-Lab is a GUI windows program, so you need to open a window that you can write within first. There's a Community.Components function called CommentaryWindow() that will do this automatically for you. Checkout the example: http://www2.wealth-lab.com/WL5Wiki/CommentaryWindow.ashx There is another Community.Components function for writing to the Clipboard as well.

You might be able to use the WL PrintDebug() window, but you would have to first pass an instance of WealthScript into that call, which is more complicated than simply calling the CommentaryWindow() extension method. I wouldn't use the PrintDebug() approach under Visual Studio.

QUOTE:
It doesn't matter whether I use "System.Console.WriteLine" , System.Console.Write...
And that's not going to work because Wealth-Lab isn't a command line program, so it doesn't have a console window to write to in the first place. But if you're writing a command line program, Console.WriteLine() should work just fine.
profile picture

Eugene

#27
Hallo Waldemar,

What you're trying to do can be accomplished in Debug mode if you simply replace your WriteLine call with this proper one:
CODE:
Please log in to see this code.

Now check out the Output window in VS and see the desired output. ;-)

However as superticker points out, there's little sense in doing so as this could be (more) easily achieved using PrintDebug or CommentaryWindow (copying to clipboard or even writing to RTF file from C.Components are too "exquisite" for this type of task). Visual Studio's extensive debugging capabilities already let you inspect the state of any variable without inserting an explicit debug instruction into your Strategy code. Just set a breakpoint, simple or conditional, and when it gets hit you mouse over a variable or use the Autos/Locals tab. Here's a good entry-level animated tutorial:

Tutorial: Learn to debug C# code using Visual Studio
profile picture

WW

#28
Hello superticker. You're right, the operation is not for debugging. Thank you for the information.

Hello Eugene.

Thank you for suggetion. This one worked.
With "console Write" the output occures side by side. With PrintDebug the output occures one below the other. I want the output side by side.

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).