PrintDebug a DataSet's symbols and their last closing price
Author: hmg2020
Creation Date: 9/16/2009 3:31 PM
profile picture

hmg2020

#1
Can you help me print a DataSet's symbols (all in the dataset) and their last closing price using PrintDebug?
profile picture

Eugene

#2
Run on any symbol of the DataSet (i.e. single symbol mode):
CODE:
Please log in to see this code.
profile picture

hmg2020

#3
Eugene, this gives me the previous day close and not todays
profile picture

hmg2020

#4
Only the symbols I am running the code in gets todays value.
profile picture

Eugene

#5
Today's partial bar isn't meant to be accessed in Strategies.
profile picture

hmg2020

#6
Can't we put the DataSet symbols with their last price in a list and then print the list?
profile picture

Eugene

#7
Sure, see the QuickRef example for SetContext. Just one of the many .NET lists, SortedList.
profile picture

hmg2020

#8
I got it, if you set the SacelWeekly you will get the last price current, then you set the savel back to what you are using other than weekly. This solves the problem.
Now, how to sort in order of price rather than symbol?
profile picture

Eugene

#9
Basically you need to reverse the key and the value. See some SortedList documentation on the internet (e.g. MSDN or simply Google), or replace SortedList with another sortable collection.
profile picture

hmg2020

#10
Eugene, I am not very good with this.
This is what I have so far with you help and it is working great.
Can you help me sort the debug output by PRPcst[str].

Thanks

CODE:
Please log in to see this code.

profile picture

Eugene

#11
I decided to rewrite your code to make it more clear and object-oriented. I highlighted some points of interest with numbers to help you understand what's going on here.

1. Instead of a bunch of SortedLists that are hard to manage, let's pack all of your bits and pieces of data for a single symbol in a custom class i.e. SomeData
2. Next, we'll create just one generic List that will hold your customized data types i.e. List<SomeData>
3. To make your list sortable, let's implement the IComparable interface. This is going to sort by PRPc in ascending order. This way, you can implement any kind of custom sorting.
4. What if you want the opposite i.e. sort by percentage change in descending order? You haven't specified that. After sorting, use the .Reverse method of the List object to sort backwards.
5. Pass your various data in one shot to SomeData's constructor when you create an instance of that class.

Sorry for some geek speak, run it to see that it's much easier than seems:
CODE:
Please log in to see this code.
profile picture

Cone

#12
I saw this thread yesterday and the multi-list solution, and was hoping you'd suggest this method. :)
profile picture

hmg2020

#13
Thank you, this is great...
Just a minor fix, ... the last to print is Volume (VOst), and it should be collected last as well.

Thanks for all your work
profile picture

hmg2020

#14
I am running into a problem with printdebug. It will not accept a large number of outputs. Is there another way to print, maybe into Microsoft word?
profile picture

Eugene

#15
Yes. Wealth-Lab is a .NET application, so probably almost any way that .NET provides goes e.g. file operations, clipboard (btw Community.Components has a handy method for copying to clipboard.) Search MSDN or Google for more, there are thousands of examples and instructions.
profile picture

hmg2020

#16
Do we have any examples around here?
profile picture

Eugene

#17
Yes, we have some examples of file operations here on the forum and in the WL5 Wiki if you search. As I stressed, Wealth-Lab is a native .NET application. You need to realize that your request is very common in the .NET world.

For a couple of helpful C# tutorial links and some C# 101 to help you learn it yourself, see this FAQ in the WL5 Wiki:
How do I start with C# ?
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).