Debug Strategy Code
Author: Andrekiekow
Creation Date: 2/21/2010 2:32 PM
profile picture

Andrekiekow

#1
Hellow

I would like to debug my code in wealth 5 with sharpdeveloper or microsoft visual C# express, anyone knows how can i integrate with wealth5(step by step).

Thanks
André
profile picture

Eugene

#2
profile picture

xayaraj

#3
Please explain how to use the StrategyHelper in step 6. Is there an example to look at? What is the Guid property "DC891C92-F211-42d1-927C-36A6ECB64CD6" for?
profile picture

Eugene

#4
I can't say better about GUID than Wikipedia: Globally Unique Identifier

Step 6 is explained well if you read the articles, and I even posted an utility for us Express version users that generates a Guid and pushes it in the system clipboard.

Perhaps the best for you would be to download the ActiveTrader Strategy Pack source from the Wiki and see it all in action.
profile picture

Andrekiekow

#5
Eugene

This example is confuse and long, I think if you put the source code will be favorable to the clients!

Thanks
profile picture

Eugene

#6
AndreKiekow

For the clients - and everyone who can browse and search the Wiki - its source code is already there for a long time. But you're a software pirate as we've determined in the support ticket.

If the step-by-step tutorial by Glitch on debugging seems "confusing and long" to someone, then they might need to read a C# 101 book as suggested here: How do I start with C# ?
profile picture

trader rog

#7
I'm having a little difficulty trying to use Visual Studio to debug. Can someone please elaborate a little more to a non-programmer type such as myself on how to do this. I tried to follow the instructions above but got hung up on creating a file "TestLibrary.csproj.user." How do you create this file using Visual C# 2010 Express? Sorry to post such a rudimentary question but it's tripping me up regardless.
profile picture

Eugene

#8
You need to create this file manually (using a file manager) and edit it in Notepad (as suggested in the article).

Not 100% sure about VS 2010 Express but in 2005/2008 that scheme works well.

profile picture

rick1222

#9
Hi Eugene

Does the Wealth lab pro c_sharp supports the #include directive key word?
This was what I thought might work to break a long strategy code into multiple files. but not.

Thanks
profile picture

Eugene

#10
The #include directive isn't supported by C# and it's not required.

First, what for would you like to break it into multiple files? I guess not for conditional compilation but to reuse classes, right? Practically (stuff like dynamic compilation aside), can't break a strategy into multiple files other than by:

1. either turning it into a compiled one first i.e. by building a strategy library. In the library you have the freedom to define as many classes as needed. This tutorial focuses on how to set up your own strategy library (that you can use not only for debugging of course):

How can I debug my trading strategies in Wealth-Lab?

And here's an open source project example of an actual strategy library:
Home - Strategies.ActiveTrader

2. or moving portions of your code to compiled libraries (assemblies) and reusing them in your WealthScript Strategy:

Is there a way to reuse a function in Strategies? Is it possible to create a library of reusable functions?

A good working example is our Community Components library (open source). There's a benefit: your Strategy code stays editable in the Wealth-Lab's built-in Editor (unlike compiled strategy libraries which can only be modified in an external IDE).

I'd suggest option #2 as more simple/convenient. Don't forget to check out Strategy Window > Strategy Window Views > Editor > References... in the Wealth-Lab User Guide, you'll need it to reference to your external compiled library of functions and methods.
profile picture

rick1222

#11
Hi Eugene

I have been following your past posts to learn how to debug strategy in MS visual C# IDE, I come to a point with error on the two statements in the Execute()
CODE:
Please log in to see this code.


my guess is that for SMA, I need to add a reference but I don't know which *.dll to include from the wealthlab executable directory.
And for the Color, the syntax for PlotSeries is System.Drawing.Color, however, the IDE does not allow me to add using System.Drawing nor accept the full name System.Drawing.Color put into the parameter.

Thanks for your help

profile picture

Eugene

#12
For SMA, just add a reference to WealthLab.Indicators.dll.

Re: System.Drawing -- I'll deliberately leave this question for you to resolve on your own by checking out MSDN (Google, or any other available C# resource). Trust me, you will need this skill later on a regular basis so better be prepared to search for the code examples if you're not sure how to use Color.
profile picture

rick1222

#13
Hi Eugene,

First, I find out how to using System.Drawing;,

In retrospect, it is rudimentory, for others to know, one needs to add a reference (System.Drawing) to the project, which I suppost has already done in wealthlab-pro.

Now my simple code compiled successfully and a new dll generated in the directory (window xp) C:\Program Files\Fidelity Investments\Wealth-Lab Pro 6

However, when I try to use the new strategy, I don't see the newly created dll listed as shown in the step 14.
http://www2.wealth-lab.com/WL5WIKI/kbAskGlitchDebug.ashx
I have tried to move the *.dll to a few directories but none can make it appear in the strategy list.

Any hint you can provide for me to follow and get this one resolved?

Thanks for your help

>>b.t.w, I did use net Framework 2.0, with the Default namespace ClassLibrary1, should I use a special namespace here?

>> I changed the Default namespace to WealthLab.Strategies and that caused the wealth-lab crash. This is good that I know wealth-lab can see it and has tried to load it. still I cannot figure out what else to do to make it right
profile picture

Eugene

#14
Make sure you've restarted WLP and the strategy library will appear (step 14), assuming that you followed all the other steps carefully and double-checked everything.
profile picture

rick1222

#15
Hi Eugene

My tiny code still has issue to show up inside wealth-lab. However, I got the Strategies.ActiveTrader pack (downloaded from wiki) compiled and step-in line by line in debug mode. So I have a working example to compare.

Thanks for the help, you are a great support!
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).