Referencing and calling external .net dlls
Author: daronow
Creation Date: 1/19/2008 3:33 PM
profile picture

daronow

#1
Wealth-Lab (.NET) 5.0

Is there any way to use and call external .net dlls from WL5? For example System.Xml or MyNumberCruncher.dll?
profile picture

Eugene

#2
Dave,

The assembly must be dropped in WL5 directory, then the usual using MyNumberCruncher line is added -- or are there strings attached?
profile picture

daronow

#3
Cool, thanks. Next question -- how to get intellisense going for it? I think I already know the answer -- write it in Visual Studio :P
profile picture

Eugene

#4
P.S.
The assembly must be dropped in WL5 directory...

Try to copy System.XML.dll from:
%windir%\Microsoft.NET\Framework\v2.0.50727\

;)
profile picture

daronow

#5
Following up on this, how do I code my strategy entirely in my own dll and then call it?

I created a DLL with the following as the only class file
(and referenced the WealthLab DLLs from my DLL):

CODE:
Please log in to see this code.


I then copied this TestStrat.dll to the WL5 folder, and created the following script in WL5:

CODE:
Please log in to see this code.


When I hit compile I don't get a result. If I insert a typo into the TestStrategy class name (for example Test_Strategy) I get a compile error (as expected). But I don't get a message that it compiled successfully (or failed) when I hit compile, and when I hit "Run the strategy" it switches to the chart view (as if it ran the strategy) but nothing is printed in the debug window (if I add more code to the execute method that code doesn't execute either).

Thoughts?

Dave
profile picture

Cone

#6
First, an update on the original question - the ability to create references to .NET Assemblies is coming in Version 5.1.

<< how do I code my strategy entirely in my own dll and then call it? >>

A detailed answer is in the works here mainly with debugging instructions, but the easy answer to this is once you compile your dll and drop it in the WL5 folder...

1. Restart WLP5
2. Select your strategy from the Strategy Explorer.

That should be it.
profile picture

Eugene

#7
2. Select your strategy from the Strategy Explorer.

I thought he should be additionally impementing StrategyHelper for that?
profile picture

Cone

#8
Yes, of course. Let me work up an example.
profile picture

Cone

#9
Here you go. There will be more details published later, including how to use this Helper with debugging. For now, just follow the lead and see the comments.

CODE:
Please log in to see this code.

Compile that, and drop the Assmbly (dll and pdb files) in the WL5 directory. Restart WL5.
profile picture

daronow

#10
Just a heads up, when I run a script in an external DLL the Performance tab is blank. If I then run it a second time I get a second Performance tab, and there's nothing in the tab (when there's only one it's an empty white results pane, when there are two the results pane is gone).

Note the trades are OK and the equity curve is also OK, so it's just the results pane. Is there any workaround for this or is this somehow caused by something bad I'm doing in my strategy (I tried it with a random entry generator that just enters and exits and got the same problem).

Dave
profile picture

Eugene

#11
Hi Dave,

You seem to be doing about right in your code because I can confirm this sort of stuff is going on. Please create a support ticket.
profile picture

daronow

#12
OK, I'll create a ticket. It's not a pressing problem for me since I'm mostly running scripts in WL5 itself, but as people implement 3rd party script DLLs this is going to be an issue.

Dave
profile picture

Eugene

#13
Dave, sorry but please could you re-open the ticket? Chances are it could take less time to fix than expected. Thank you.
profile picture

Cone

#14
I'll reopen it (users don't have that priveledge).
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).