Using multiple files for multiple strategies at once
Author: UpperThrower4
Creation Date: 10/10/2020 6:29 PM
profile picture

UpperThrower4

#1
Hey there, my goal is to have one file with multiple classes that each of them represents an entry signal or an utility that can be used later(called on the file as TrapCompra, TrapVenda...) . Basically, I want to create a library, however, after trying many different ways (using statement, interfaces...), I couldn't.

The classes, if in the same file, work correctly, so they`re not the problem.

Thank you in advance!
profile picture

Eugene

#2
Olá Leonardo,

It doesn't work this way in Wealth-Lab. You have to organize your class(es) in a Class Library (i.e. a DLL which targets .NET 4.6.2 or higher) and compile it in Visual Studio Community 2019. Then you could refer to it via a familiar "using" clause and call the methods of the Utilidades class.

Here's an example of a Wealth-Lab 6 function library:

Home - Community.Components
profile picture

UpperThrower4

#3
Thank you, it helped me. But there`s another thing: I`ve built the library and made it into a DLL which targets .NET 4.7.1, then I moved it to the same folder of WealthLab.dll, Wealth-Data.dll. Then, I tryied to install it via REGSVR32.EXE, regasm, just importing the DLL .But nothing works. I keep getting the same errors:
1) RegAsm error RA0000 Could not load file or assembly on Network Drive
2) The module Sinaisl.dll was loade but the entry-point DLLRegisterServer was not found

Any thoughts? Maybe I`m not building it the right way (creating the DLL)

Thanks again!
profile picture

Eugene

#4
Neither REGSVR32.EXE nor regasm are required. Just placing the DLL in the main folder should work.

However, there's a disconnect between what you intended to do (in post #1) and what you're actually coding in VS. For a true utility library, it's not required to inherit WealthScript (as per your 2nd screenshot). Take a look into the Community Components code for insight.

1. If you're after making a library of reusable functions like UltimoTopo and the like which you can reference in a strategy in the Editor (or in a compiled strategy), go for C.Components sample code. That's your goal. No need in WealthScript inheritance, having void Execute() etc.

2. Self-contained strategies can also exist in compiled libraries but that's not about reusing code:

Home - Strategies.ActiveTrader
How can I debug my trading strategies in Wealth-Lab?
profile picture

UpperThrower4

#5
Main folder would be the same os WealthLab.dll? C:\Program Files\MS123\Wealth-Lab Developer 6?

Maybe my DLL was really broken, since I've tried just dragging it in there.

1 - I thought I had to use the WealthScript inheritance, now I'm going to see some sample code from C.Components and try again, then, I'll give you a feedback.
2 - You are right, that would make no sense at all.

Many thanks, once again!

profile picture

Eugene

#6
QUOTE:
Main folder would be the same os WealthLab.dll? C:\Program Files\MS123\Wealth-Lab Developer 6?

Right, then it will be picked up automatically by WL. That's the recommended way.

As a less convenient alternative, you can place the file anywhere else and use the Strategy Editor > .NET References > Other..., click "Add a Reference..." This applies to the current strategy only but there's a way to make the reference global for newly created strategies: WL's Edit menu > "Save as Default Template Code". Not suggesting you'd do this, just FYI.
profile picture

UpperThrower4

#7
Okay, got it.

When I delete the WealthScript inheritance it gives me errors like "the name High does not exist in the context".
profile picture

Eugene

#8
Check out these topics, they all tell the same thing and should bring you up to speed:

Subclass from WealthScript
WealthScript Inheritance #1
WealthScript Inheritance #2

Also see the Community Components sample code. There are tons of examples e.g.

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

UpperThrower4

#9
Hmmmm, really helpful!

Thank you for your time Eugene!

Have a nice week!
profile picture

Eugene

#10
De nada.
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).