Creating New DataSeries
Author: ronc
Creation Date: 1/20/2013 5:14 PM
profile picture

ronc

#1
Section 6.1 of the Wealthscript Programming Guide shows 2 ways to access DataSeries:
METHOD 1: SMA sma = new SMA(Close, 50, "50-day SMA");
METHOD 2: DataSeries sma2 = SMA.Series(Close, 20);
The Guide says that Method 1 is preferred. However, it seems that it sometimes works and sometimes does not. For example:

This does NOT work: ADX adx = new ADX(Bars, adxPeriod);
But this DOES work: DataSeries adx = ADX.Series(Bars, adxPeriod);

When should we use Method 1 vs Method 2?

Also, when accessing all of the indicators I have used thus far, based on Closing price, I pass the Close object:
RSI rsi = new RSI(Close, RSIperiod, "RSI");
But for ADX, this does not work; ADX seems to only work when being pass the Bars object, but I thought we needed to specify, Open, Close, etc. Why is this?

Thanks!
Ron
profile picture

Eugene

#2
Re: Method1

As indicated on its online help page, the ADX does not have a constructor, so you just have to use the Series method:

http://www2.wealth-lab.com/WL5WIKI/ADX.ashx

When an indicator provides the two methods, it is mostly a question of preference whether to use the constructor or the Series method. Please check the Wiki as the guide to determine if the "new" constructor (aka Method1) is available or not.

Re: ADX and Close

Well, it simply means that the indicator which accepts the Bars parameter will use its Bars.High, Bars.Low etc. properties according to its internal logic. The ADX can not be applied to Close by design.
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).