Simple example using WealthScript as class library from Visual Studio
Author: aykuts
Creation Date: 4/3/2014 2:27 PM
profile picture




I want to write a simple console application in VISUAL STUDIO that basically runs a code that is very much like a typical strategy code. (i.e. a code that basically does what a typical code-based strategy does: it captures Bars data, then performs certain calculations, and, finally, loops over the bar++ and generates Buy or Sells as a result).

I am not that competent about the .NET environment, and basically I simply could not figure out the way I can make the WealthScript methods and properties usable and callable from my Console Application.

I get the following error:
"Cannot create an instance of the abstract class or interface Wealthlab.Wealthscript"

My question is: how can I create an instance of WealthScript? I know that this question is about the very fundamentals of c# and confirms that I simply dont master the very logic of object programming. Nevertheless, the little tweak you provide now might help me learn and proceed further.

Thanks in advance for your help.

Aykut Saribiyik

I attach here a simplistic version of my code, and I think things will be much easier once I manage to create an instance of WealthScript.

Please log in to see this code.
profile picture


What you're trying to do, i.e. power an external application with the WealthScript library, is generally unsupported. Can you tell us what's the point of this, or why won't you put your logic in WealthScript Strategy and/or call it from a class library instead?

As to WealthScript being abstract class, it can only be implemented, not instantiated. An illustration of that is provided in the article below that shows how you can create a compiled Strategy in Visual Studio:

Programming | How can I debug my trading strategies in Wealth-Lab?

profile picture


It's easier+faster to develop strategies in Visual Studio since Unit Tests and Regression Tests can be added.
For a WL newbie like me, it's good to know early on that it can't be done. Probably have to settle for developing and mocking the behavior of Bars and DataSeries, and hope it still works (correctly) when I copy/paste the code into The WL strategy Editor.
profile picture


Re: mocking, you might find this thread useful: How to set read-only Position properties in Visualizer?
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).