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.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color: