Indicators are presented in two categories: centered, and banded. Centered
indicators are unbound and oscillate around zero. Banded indicators oscillate
between 0 and 100 (-100 for the Williams %R), and usually have standard 'overbought'
and 'oversold' levels. Overbought/Oversold levels are
provided as a reference only, and do not represent buy/sell reccomendations.
Global Syntax
All indicator and overlay functions have the same core syntax. Let genfunc
represent any indicator or overlay function included in this toolbox, and
MyStocks a stockasset object with some historical stock data. The table
below describes the methods by which genfunc
can be invoked. If MyStocks is a [1 x N] array
of N stock asset objects, then the output is
a [1 x N] cell array of numeric column results. Otherwise, the
output is a numeric column array.
Methods for invoking indicator functions
| Type |
Syntax |
Output |
1 |
MyStocks.genfunc(arg1,
arg2...)
|
[1 x numel(MyStocks)] cell |
| 2 |
genfunc(MyStocks,
arg1, arg2...) |
[1 x numel(MyStocks)] cell |
3 |
genfunc(MyStocks(iStock),
arg1, arg2...) |
[numel(MyStocks(iStock).Dates) x 1] double |
4 |
genfunc([numeric
array], arg1, arg2...) |
[size([numeric array],1) x 1] double |
Description
- Indicator and overlay functions called as a Method of a stockasset object.
- Indicator and overlay functions with stockasset object input.
- Indicator and overlay functions with indexed stockasset object input.
- An [n x m] double array of the appropriate historical data as input. The
data must be in column format.
back to top
Examples
Global Syntax Methods
First create a stockasst object with 1 year of historical stock data:
DateRange = '1year';
EndDate = datevec(now);
StockList = {'DIS', 'PG', 'JPM', 'XOM', 'JNJ','GE', 'MSFT', 'EXC','MON'};
MyStocks = stockasset(EndDate,DateRange,StockList);
To explicity handle the historical data for 'JPM' (for example), the third
stock in the list, parse MyStocks:
Open = MyStocks(3).Open;
High = MyStocks(3).High;
Low = MyStocks(3).Low;
Close = MyStocks(3).Close;
Volume = MyStocks(3).Volume;
Calculate the Accumulation/Distribution using the different Syntax:
AccDist1 = MyStocks.accumdist;
AccDist2 = accumdist(MyStocks);
AccDist3 = accumdist(MyStocks(3));
AccDist4 = accumdist([High Low Close Volume]);
AccDist1 and AccDist2: Since MyStocks
is a [1 x 9] array, AccDist1 and AccDist2
are both [1 x 9] cell arrays. Each cell contains the accumulation/distribution
for the associated stock in MyStocks:
AccDist1{1} = [251 x 1 double] for MyStock(1)
AccDist1{2} = [251 x 1 double] for MyStock(2)
AccDist1{n} = [251 x 1 double] for MyStock(n)
AccDist3: Since MyStocks(3) indexes
a single stockasset object, AccDist3 is a [251
x 1] double:
AccDist3 = [251 x 1 double] for MyStock(3).
AccDist4: The required inputs for accumdist
are [High Low Close Volume]. When these are
explicity input into the function, the output AccDist4 is a [251 x 1] double:
AccDist4 = [251 x 1 double]
back to top