ATRP2 (and ATR2)
Author: Sammy_G
Creation Date: 7/16/2010 2:26 PM
profile picture

Sammy_G

#1
Eugene, if its not too much of a hassle, can you look into including these two WL4 custom indicators into Community Indicators? The discussion for their need, and advantages over the native WLab ATRP and ATR indicators, is here: /Forum/Posts/ATR-Simplified-18637&start=0
ATRP2 code is here: http://wl4.wealth-lab.com/cgi-bin/WealthLab.DLL/libraryview?item=419
ATR2 code is here: http://wl4.wealth-lab.com/cgi-bin/WealthLab.DLL/libraryview?item=417

Thanks in advance.
profile picture

Eugene

#2
That's a one-liner, actually we're not including such indicators in Community.Indicators (a minimum of 4 simple math operations):
CODE:
Please log in to see this code.
profile picture

Sammy_G

#3
I see your point. That's OK.


May I suggest a couple more of WL4 custom indicators?
- ZScore
- RunsZscore

Really useful.
profile picture

Eugene

#4
Not sure what RunZscore is, but ZScore is a one-liner again (we already have it inside the MAC-Zscore and AggZ in Community.Indicators):
CODE:
Please log in to see this code.
profile picture

Sammy_G

#5
In WL4 there were functions - a block of code with its own variables and result, which was segregated from the main script for purposes of clarity & convenience. The main script then utilized the re-usable code of the function by passing various series or parameters, so the code didn't have to be duplicated each time, just the new series and/or parameters needed to be passed, with resultant new series or values.

How does one create the equivalent of a function in WL5? Using Zscore as an example, can you explain how to do it, and then using the Zscore "function" in the main script to get different values (for Close, Open, etc.)? [Use of the simple Zscore series is for convenience; the method will likely be used for longer code snippets.] Or is there a tutorial or KB article explaining how to do this?
profile picture

Eugene

#6
QUOTE:
How does one create the equivalent of a function in WL5?

You need to create a library (like Community.Components) which will store your functions and methods, add a reference to it in your Strategy (or place it in Wealth-Lab's main folder), and a "using" directive on top of the strategy.

QUOTE:
Or is there a tutorial or KB article explaining how to do this?

No, since such a library is just a pretty standard Class Library, nothing WLP-specific in here. General principles apply. Download the Community.Components project from the Wiki to have a working example. But since you're wondering about "blocks of code" (which are called functions and methods), I'd suggest you start right here:

How do I start with C# ?I'm a Wealth-Lab 3/4 user, how to learn C# ?
profile picture

Sammy_G

#7
I had something like this in mind:
CODE:
Please log in to see this code.


I need assistance with these issues I ran into:
1. Couldn't create the Value method (the one that returns value of the series at a specific bar)
2. When you create a series using the 'new' argument, do you always have to specify your own description, or can you retrieve the description as coded in the function?
profile picture

Eugene

#8
CODE:
Please log in to see this code.

Better call .Series[bar] instead of .Value here.
QUOTE:
1. Couldn't create the Value method

Check out the TASCIndicators project's source code in the Wiki for an example how should the .Value method be coded.
QUOTE:
2. When you create a series using the 'new' argument, do you always have to specify your own description, or can you retrieve the description as coded in the function?

Please check out the QuickRef > DataSeries Object.
profile picture

Sammy_G

#9
Called the Series:
CODE:
Please log in to see this code.

Values appear to be the same. Did you advise that for speed, or are the calculations more accurate?


1. Value method created.

2. I have not been able to find a single instance where the 'new' argument was NOT accompanied by specifying a string. So it would appear that you can't get the series' default description using 'new', you have to use
DataSeries (name) = ...
Correct me if I am wrong.
profile picture

Eugene

#10
QUOTE:
Values appear to be the same. Did you advise that for speed, or are the calculations more accurate?

For speed's sake. The .Value method is used when you need a one-time calculation that does not look up the value in the cached data series.
QUOTE:
So it would appear that you can't get the series' default description...

Upon calling the static Series method, Wealth-Lab generates a description string based on the input parameters - e.g. "Z-Score(Close,10)", which is then being used for caching purposes.

When creating a new DataSeries, you're really creating a new, empty DataSeries filled with zeroes, hence the need to specify a unique description.

(Note: a series' description is available by reading its .Description property.)
profile picture

Sammy_G

#11
Most indicators in WL5 are named thus:
Indicator(DataSeries,period).

SO Wealth-Lab caches them when they are first created, and reuses them. But the name is not unique as it doesn't have the symbol name, so all symbols will create indicators with identical names. Wouldn't that create a problem if you are running say a Rotation script and the same indicator series gets used each time as the name is not unique?
profile picture

Eugene

#12
No, they are unique as it's the Bars.Cache property where they get placed. Simply put, WL actually has a collection of "Indicator(DataSeries,period)" where each entry belongs to a Bars object.
profile picture

Sammy_G

#13
Got it.

Thanks for the assistance and all the other useful info.
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).