Error in non-compiled strategy when compiled strategy added to WLP
Author: Carova
Creation Date: 6/18/2018 10:38 PM
profile picture

Carova

#1
Hi!

Got my compiled strategies resolved and working (Thanks! Eugene and superticker for the help!) However I now have an issue and it is not clear what I am doing in my compilation that is causing the problem.

When I run any of my non-compiled strategies I get something like the attached error. What am I doing wrong?

Vince
profile picture

superticker

#2
I'm confused. Are you saying you can run your strategy successfully under the Visual Studio debugger, but not from the WL editor? All C# code is compiled into Intermediate Code (IC) then JIT'ed on run-time into native object code. There's no such thing as non-compiled C# code.

Please list all your using statements. Apparently one is either misspelled or the DLL file reference to one is duplicated in two locations. You may need to list all your DLL file references as well, but lets start with the using statements.

The DLL file references typically need to be in the startup directory of the program (Wealth Lab) unless they are part of the Microsoft .NET framework or Windows OS. I would not point references to these files to your Visual Studio project directory unless you know exactly what you're doing. For my own WL projects, I let the Visual Studio IDE copy my DLLs to the WL program directory during the VS "Release" build process.

Here are my using statements, but you don't need all of these.
CODE:
Please log in to see this code.
profile picture

Eugene

#3
The compiler tells you what went wrong:

Compiler Error CS0433

When compiling your strategy library you've committed an error but, obviously, without reviewing your namespaces and using statements (as superticker suggests) we're stuck. However, the namespace "WealthLab.Strategies.WealthLab" looks clearly odd and is probably the culprit of your trouble.

Did I suggest that you adopt the open source library code: Home - Strategies.ActiveTrader before? (Yes I did).

That's what one might get when reinventing the wheel and shunning the working design pattern. ;)
profile picture

Carova

#4
Hi superticker!

Sorry for my poor explanation (I was really tired from trying to solve this problem myself over MANY hours)...

I have successfully used VS to compile my code with the following:
CODE:
Please log in to see this code.


and when I open WLP I can find and run the compiled code. However if I run a non-VS compiled strategy in WLP the JIT compiler throws the errors that I posted.

I hope this makes more sense.

Vince
profile picture

Carova

#5
Hi Eugene!

Yes, I did use the Active Trader code as you suggested but I found that it was missing many needed "using" statements which I added (after trying to figure out what was missing). The red underlines tells you what is wrong and then leaves you the fun part of figuring out why it is complaining. ;)

Vince
profile picture

superticker

#6
Isn't a constructor for your strategy class (in this case, "WealthLab") required?
CODE:
Please log in to see this code.

Rather than naming your strategy "WealthLab", you might pick a more descriptive name that sets it apart from other strategies you might be running. For example, "Bull_Run" if it's a buy high strategy.

You'll need some executable statements in the Execute() block to make this functional. How about adding something in there that's executable.

I don't think you need the interface definition block as yet. I would get a "hello world" strategy working first before creating and calling subclasses requiring an interface. Personally, I do use many subclasses (in a private DLL component library) in my strategies since they all share common functions. But all these subclasses started in the main strategy code, then--after debugging--were moved into a class of their own. But they didn't start out that way. That's added later.

If you want to add your subclasses to your strategy via inheritance, then you'll need an interface block. But using that inheritance approach is not required. I simply call my subclasses directly without inheriting them on the strategy class definition line. Most WL users use that direct approach. Except for a few .NET types, none of my own code employs an interface block.
profile picture

Eugene

#7
QUOTE:
Yes, I did use the Active Trader code as you suggested but I found that it was missing many needed "using" statements which I added (after trying to figure out what was missing). The red underlines tells you what is wrong and then leaves you the fun part of figuring out why it is complaining. ;)

Vince, the References block in this solution contains dependencies from the WLD installation folder. Since they don't exist on your machine, the problematic assemblies are highlighted by VS. You should point to them by making them point to the WLP main folder. Once this is done the solution should compile in VS w/o an issue.

In general, @superticker makes all good points. Your code is completely incomplete (pun intended) so no surprise it throws off Wealth-Lab. Just use the working example or implement WealthScript as required.
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).