WealthScript Inheritance
Author: bitza
Creation Date: 8/6/2010 5:02 AM
profile picture

bitza

#1
Hi!
I have a question about WealthScript class inheritance.
My goal is to extend abstract WealthScript class by making an inheritance, for example like this:
CODE:
Please log in to see this code.

Code is compiled without any errors in a Wealth-Lab code editor, but still it doesn't work.
But if put this code in a precompiled form (by creating a Class Library), this code will execute correctly.
Can I use an inheritance within Wealth-Lab code editor?

Thanks.
profile picture

Eugene

#2
Hi,

Let's start with why'd you want to extend WealthScript?

For example, you could use WealthScript methods without having to implement it:

Example 1:
CODE:
Please log in to see this code.


Example 2 by Aleksey:
CODE:
Please log in to see this code.

profile picture

bitza

#3
Thanks' for you fast reply.
QUOTE:
Let's start with why'd you want to extend WealthScript?

I want to add an extra Properties and Method that depends from WealthScript methods results. Just for example:
CODE:
Please log in to see this code.

QUOTE:
For example, you could use WealthScript methods without having to implement it....

Yes, but I thick inheritance from WealthScript is more reasonable.
profile picture

Eugene

#4
QUOTE:
I want to add an extra Properties and Method that depends from WealthScript methods results.

OK, but why complicate things? You can do that w/o inheriting WealthScript.
profile picture

bitza

#5
QUOTE:
You can do that w/o inheriting WealthScript

Could you please give a code example of this?
Imagine that I need to make a default template code with all my own properties and method available and without adding external classes (to avoid code duplication).
If an inheritance from WealthScript is available, I just make a class library, with my abstract class inherited from WealthScript, compile it in Wealth-Lab folder and set a new template code with my assembly referenced. I don't think it's complicated.

Thanks.
profile picture

Eugene

#6
QUOTE:
Could you please give a code example of this?

What I was meaning to say is that it's practical to create your library of functions like Community.Components, add your properties and methods, then add a reference to the assembly in the Strategy Editor > References > "Other assemblies to reference", and save the resulting code as Default Template Code.
profile picture

Eugene

#7
pubx101 asked this question in a duplicate thread (3rd because another "WealthScript Inheritance" exists):

I knew that a similar question was asked before but the link to the ask is not available now.

I want to add more functions to class WealthScript, I tried something like this: ( I will use MyScriptExt as template for all strategies)

CODE:
Please log in to see this code.


the program can compile but not run. what did I do wrong?
profile picture

Eugene

#8
QUOTE:
I knew that a similar question was asked before but the link to the ask is not available now.

I believe it's a suboptimal idea to create a duplicate thread in this case. Instead you might simply request to fix the broken link or provide an example. This has been done here and in the other thread:

WealthScript Inheritance
profile picture

pubx101

#9
thank you for the fix. I already did as you suggested, but it makes more sense to implement in subclass for some functions. for example, some stock exchanges have daily price change limit (+/- 10%), I want to override certain trading methods (i.e. BuyAtOpen() ) with the rule. Is it possible to have a subclass of WealthScript ?
profile picture

Eugene

#10
QUOTE:
Is it possible to have a subclass of WealthScript ?

Please refer to this topic: Subclass from WealthScript
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).