Custom indicator in separate strategy
Author: Straddle
Creation Date: 6/27/2009 10:23 AM
profile picture

Straddle

#1
I'm refering to the following sample code from the WealthScript Programming Guide "How to: Return an "Absolute Value Series":

CODE:
Please log in to see this code.


I would like to save the custom indicator function "LessThanCountSeries" in a seperate script so that various other scripts can refer to the function. How can I do this? When I save it in a separate script and try to refer to it from another script, I get the error message that "LessThanCountSeries" cannot be found in the current context.

Thanks in advance.
profile picture

Cone

#2
That's because it's not in the current context ;)

The correct way to accomplish this is to create an indicator library, like the Community.Indicators extension, whose source can be found on the Wiki. In v5, your "$Include" directive is the using statement to your compiled library of indicators. Unfortunately, it takes an extra step to get there in v5.
profile picture

Eugene

#3
Strategies can not "cross-talk", that's why your another Strategy can't pick up the indicator from where it's saved.

In order for any indicator to be used externally (i.e. in other code- and rule-based Strategies or by dragging and dropping to a chart), you need to create a separate Indicator Library (or attach the code to an existing one) and make your indicator formal (i.e. implement an interface).

It can actually sound more complicated than it is. Please see the open source Community.Indicators library for an example implemenation. Note that the project is community-driven, and many suggestions from our users ended being included there.
profile picture

Straddle

#4
Thanks for your answers, Cone and Eugene.

If I understand you correctly, I need additional software like Visual Studio to create my own indicator library. Correct?

Thanks.
profile picture

Eugene

#5
Yes, this step requires an additional software -- but the good news is that a free IDE like Visual Studio Express 2005/2008 or SharpDevelop 2.1/3.0 are just what doctor ordered for this task.

Having an IDE is also beneficial for the purpose of debugging custom strategies, indicators and function libraries.
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).