Write to Trades Performance Visualizer
Author: MarkStaunton
Creation Date: 4/1/2010 9:32 AM
profile picture

MarkStaunton

#1
Is there any way to add a column to the trades Performance Visualizer and write data to it such as the R-Multiple of a Trade?
profile picture

Eugene

#2
To the built-in performance visualizer, no.

To your own custom performance visualizer, yes. For instance, you can download Community.Visualizers demo source code and modify the PVTrades2 class that represents the Trades+ visualizer.
profile picture

MarkStaunton

#3
Tks
profile picture

Eugene

#4
P.S. In short, adding a column would take the following:

1. Add a column to the ListView (by defining a ColumnHeader) of the control.
2. Specify the type of data (i.e. double) for the purposes of sorting (notice ListViewSortManager in the PVTrades2 constructor).
3. GenerateOutput is used for copying to clipboard, so you should skip this method for now.
4. Now, in CreateVisualization method body you will need to calculate your performance metric and use AddSubItem to push it to the ListView.
profile picture

Panache

#5
I'd like modify the Profit Per Bar column in the MS123 Visualizer to make it equal to Net Profit / Avg Bars Held (or the existing Profit Per Bar * Trades).

Here's what I changed in PVTrades2.cs, which I thought might work.

GenerateOutput method
CODE:
Please log in to see this code.

CreateVisualization method
CODE:
Please log in to see this code.

I also inserted a ColumnHeader colAbacusProfitPerBar everywhere colProfitPerBar appeared.

Obviously, I've managed to screw up the Visualizer, because when I try to run an Optimization in Debug, I get an error message:

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

Am I even close, or isn't this worth my trying to learn how to modify Visualizers?
profile picture

Eugene

#6
Looks good but there's one step left. To make the columns sortable in a manner smarter than Wealth-Lab's default, Trades+ has been using an open source component called ListViewSortManager. To initialize it you should "insert a column" in PVTrades2(). Notice how each line matches an existing column. For your performance metric, a currency sort line has to be inserted exactly where appropriate (i.e. at the relative position that matches the ListView subitem).

If all else fails try inserting the ColumnHeader in the form designer.
profile picture

Eugene

#7
Kurt, this is not OK to post content made available to verified customers on the public forum. Because I couldn't delete the attachment containing MS123 code from the Wiki (and works derived from it) alone, I had to delete your entire message. Appreciate your understanding of our guidelines re: sharing MS123 intellectual property.

After making sure that target .NET framework is set to 4.5 and updating references, the solution has compiled and worked. There's no problem with your code additions except that you haven't renamed the new column and it appears duplicate.

P.S. A cosmetic issue:
CODE:
Please log in to see this code.
profile picture

Panache

#8
So sorry. I wasn't thinking about that.
profile picture

Panache

#9
I like your tabs in Trades+, and am trying to do the same thing with my Performance Visualizer. However, I can't figure out how to make the columns in the second tab sortable. I am looping back through each of the positions and, if they are active, using the same List View Item to populate the Open Positions tab. I suspect I need to create a new m_sortMgr for Open Positions, but I'm not seeing where that is transferred to the ListViewSortManager.

Can you help point me in the right direction?
profile picture

Eugene

#10
This might help as I was following these guidelines:

Adding Multicolumn-sorting to ListViewSortManager
ListViewSortManager control

You might also want to call SortEnabled as my code does for a speedup on large sets of trades.
profile picture

Panache

#11
Thanks Eugene. That got me 99% of the way there.

The last thing on my wish list is to have the PV initially sort the Open Positions tab by Symbol. I added:

CODE:
Please log in to see this code.


to my m_sortMgr for the Open Positions tab. It puts a ^ on the Symbol column in the Open Positions tab, but the Symbols aren't sorted until I click on it.

I thought Luis Ramos's improvements to the ListViewSortManager made this possible. Do you know what I'm missing?
profile picture

Eugene

#12
Have you set SortEnabled = true? Sounds like you haven't. I don't remember as it's been 4 or 5 years since I looked into it. You might want to check the open source example in the Wiki if you have doubts. Hope that helps.
profile picture

Panache

#13
I had SortEnabled = true, but maybe I had it in the wrong spot. Anyway, I finally got it to do the initial sort, so I'm on to enjoying my new PosSizer and PV.

Thanks again Eugene.
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).