Simplify Daily Decision Making: Export Performance Charts Out Of WLD
Author: tradercn
Creation Date: 10/17/2013 11:38 AM
profile picture

tradercn

#1
To simplify my decision making, I tried to write a program. Here is my thought, not sure if you are able to provide me some clues.
1, Try to read Strategy list in Strategy Monitor, want to get their names, datasets, test periods, Position sizing methods;
2, For each strategy in the strategy list, based on the specified dataset, test period, position sizing method, I wish to get their equity curves, win% charts, average profit charts, profit factor charts;
3, All the above charts will be generated daily after updating the EOD data. I wish to show these charts in Excel, or I have to write an independent program. My concern is how to make them out of WLD. Is that possible?
Thanks.
profile picture

Eugene

#2
1. The easiest way to obtain these properties is by parsing the StrategyMonitorConfiguration.xml file from user's AppData folder.
2. On calculating win rate, profit factor etc. see:

* WealthScript Techniques | Interacting Dynamically with Portfolio Level Equity
* Trading by win rate and profit factor
* MS123 Visualizers demo solution > PerformanceEngine.cs class
profile picture

tradercn

#3
Thanks so much. :)
profile picture

tradercn

#4
I looked through StrategyMonitorConfiguration.xml, but what is StrategyID? How to identify which StrategyID represent which strategy? Thanks.
profile picture

Eugene

#5
StrategyID is the Guid of the Strategy. It matches the ID property in the Strategy's XML file. To look up a Strategy by its ID, you could for example search the Strategies subfolder, looping through existing XML files and parsing them. Once you find an XML whose ID matches a given ID, you've just found your Strategy (its first instance, to be precise - there's no protection against duplicate IDs in files).
profile picture

tradercn

#6
Wonderful! Got it! You guys are amazing!
Thanks so much.
profile picture

Eugene

#7
Glad to help. There's a shortcut that you could try: the unsupported StrategyManager class from WealthLab.dll. It has a couple of methods used by Wealth-Lab internally to find a Strategy by its Guid. You will need to add an extra reference to WealthLabDev.exe before using (for WLP users, it's WealthLabPro.exe). Here's some pseudocode (on-the-fly):

CODE:
Please log in to see this code.
profile picture

tradercn

#8
This is an even more greater idea! I love both.
profile picture

tradercn

#9
For test purpose, I referenced WealthLabDev.exe and WealthLab.dll in a project. Target Framework is .NET Framework 4. In this simple project, there is a form1 contains a button and a label. Once I click the button, the label shows the Strategy Name by the GUID specified in the code. The code is almost the same as what you showed above. The only difference is the second row:
CODE:
Please log in to see this code.

Above these codes, two rows are added:
CODE:
Please log in to see this code.


After I run the above, it popped up an error message as followed:
BadImageFormatException was unhandled
Could not load file or assembly "WealthLabDev, Version=6.6.13.0, culture=neutral, PublicKeyToken=null" or one of its dependencies. an attempt was made to load a program with an incorrect format.

I guess it is because target framework, but not sure what is wrong. Could you please help? Thanks.
profile picture

Eugene

#10
You're not doing anything wrong. Sorry but this will not work. I overlooked that the code depends on an auxiliary class which is called MainModuleInstance (sic). (You can't just reference WealthLabPro and use MainModule.Instance - if only it was that simple.) And you really have to be familiar with System.Reflection to modify that auxiliary class.

Fortunately for you, installed MS123 Visualizers library will save you from the trouble of modifying that unsupported class. Add a reference to WealthLab.Visualizers.MS123.Helper.dll and this will work:

CODE:
Please log in to see this code.
profile picture

tradercn

#11
It works great in WealthLab Strategy window. But in Visual Studio project, it doesn't work neither. The code is followed:

CODE:
Please log in to see this code.


It threw a different error message:
TypeInitializationException was unhandled.
The type initializer for 'WealthLab.Visualizers.MS123.MainModuleInstance' threw an exception.


What is reason of this error please? Does that mean WealthLab.Visualizers.MS123.Helper.dll can not be referenced out of WLD?

BTW, it sounds there are lots of secrets behinds so many dlls under wealthlab directory. How to explore it? where can I get detailed information about that please?

Thanks for your quick help and patience. :)
profile picture

Eugene

#12
QUOTE:
How to explore it? where can I get detailed information about that please?


As I hinted, this is unsupported. Here is the general rule to follow:

FAQ > Is there a documentation for WealthLab.dll class procedures and methods?

QUOTE:
Does that mean WealthLab.Visualizers.MS123.Helper.dll can not be referenced out of WLD?


Of course it can be referenced. How else would MS123 Visualizers work then? :)
profile picture

tradercn

#13
Do you know what's wrong with the above code? Thanks.
profile picture

Eugene

#14
At the risk of repeating myself again, this code is an unsupported workaround. If in Wealth-Lab Strategy it works, and it does, then I have helped you. Please let the forum know if you find a solution to the error message in your VS project.
profile picture

tradercn

#15
I fully understand what you said, that's fine. I will go back to my original idea to parse xml files. Programming on WLD can not be a trading solution for me. Thank you anyway.