Indicators - Technical Analysis Toolbox™
Indicators

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.

Contents

Functions

Examples

back to top

Functions

Function List

Function Description
accumdist Accumulation/Distribution Line
avtrange Average True Range
chaikinmonflow Chaikin Money Flow
chaikinosc Chaikin Oscillator
chaikvol Chaikin Volatility
clval Close Location Value
forceindex Force Index
mfindex Money Flow Index
macdiv Moving Average Convergence Divergence (MACD)
ndayslope N day Slope
nvindex Negative Volume Index
obvol On Balance Volume
pposc Percent Price Oscillator
pvosc Percent Volume Oscillator
pvindex Positive Volume Index
pvtrend Price and Volume Trend
rateofchange Rate of Change
rsindex Relative Strength Index
fullstochastic Stochastic Oscillator
vwmacdiv Volume Weighted MACD
williamsad Williams Accumulation/Distribution
williamspctr Williams %R

back to top


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

  1. Indicator and overlay functions called as a Method of a stockasset object.
  2. Indicator and overlay functions with stockasset object input.
  3. Indicator and overlay functions with indexed stockasset object input.
  4. 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

Centered Indicators

Accumulation/Distribution

Syntax

MyStocks.accumdist;
accumdist(MyStocks);
accumdist(MyStocks(iStock));
accumdist([High Low Close Volume]);

Optional Arguments Default
none
NA

 

Example

AccDist1 = MyStocks.accumdist;
figure(1)
clf
indchart(MyStocks,AccDist1{iStock}, 'centered', '3months')
xlabel('Date')
title('Accumulation/Distribution','fontweight','bold')

image

 

back to top


Average True Range

Syntax

MyStocks.avtrange(period);
avtrange(MyStocks, period);
avtrange(MyStocks(iStock), period);
avtrange([High Low Close], period);

Optional Arguments Default
period
14

 

Example

period = 14;
atr1 = MyStocks.avtrange(period);

figure(1)
clf
indchart(MyStocks, atr1{iStock}, 'centered', '3months')
xlabel('Date')
title('Average True Range','fontweight','bold')

image

back to top


Chaikin Money Flow

Syntax

MyStocks.chaikinmonflow(period);
chaikinmonflow(MyStocks, period);
chaikinmonflow(MyStocks(iStock));
chaikinmonflow([High Low Close Volume], period);

Optional Arguments Default
period
20

 

Example

period = 20;
cmf1 = MyStocks.chaikinmonflow(period);

figure(1)
clf
indchart(MyStocks, cmf1{iStock}, 'centered', '3months')
xlabel('Date')
title('Chaikin Money Flow','fontweight','bold')

image

back to top


Chaikin Oscillator

Syntax

MyStocks.chaikinosc(fastperiod,slowperiod);
chaikinosc(MyStocks,fastperiod,slowperiod);
chaikinosc(MyStocks(iStock),fastperiod,slowperiod);
chaikinosc([High Low Close Volume],fastperiod,slowperiod);

Optional Arguments Default
fastperiod
3
slowperiod

10

 

Example

fastperiod = 3;
slowperiod = 10;
chosc1 = MyStocks.chaikinosc(fastperiod,slowperiod);

figure(1)
clf
indchart(MyStocks,chosc1{iStock}, 'centered', '3months')
xlabel('Date')
title('Chaikin Oscillator','fontweight','bold')

image

back to top


Chaikin Volatility

Syntax

MyStocks.chaikvol(emaperiod, changeperiod);
chaikvol(MyStocks, emaperiod, changeperiod);
chaikvol(MyStocks(iStock), emaperiod, changeperiod);
chaikvol([High Low], emaperiod, changeperiod);

Optional Arguments Default
emaperiod
10
changeperiod

10

 

Example

emaperiod = 10;
changeperiod = 10;
ckvol1 = MyStocks.chaikvol(emaperiod, changeperiod);

figure(1)
clf
indchart(MyStocks,ckvol1{iStock}, 'centered', '3months')
xlabel('Date')
title('Chaikin Volatility','fontweight','bold')

image

back to top


Close Location Value

Syntax

MyStocks.clval;
clval(MyStocks);
clval(MyStocks(iStock));
clval([High Low Close]);

Optional Arguments Default
none
NA

 

Example

clv1 = MyStocks.clval;

figure(1)
clf
indchart(MyStocks,clv1{iStock}, 'centered', '3months')
xlabel('Date')
title('Close Location Value','fontweight','bold')

image

back to top


Force Index

Syntax

MyStocks.forceindex(period);
forceindex(MyStocks, period);
forceindex(MyStocks(iStock), period);
forceindex([Close Volume], period);

Optional Arguments Default
period
13

 

Example

period = 13;
findex1 = MyStocks.forceindex(period);

figure(1)
clf
indchart(MyStocks,findex1{iStock}, 'centered', '3months')
xlabel('Date')
title('Force Index','fontweight','bold')

image

back to top


MACD

Syntax

MyStocks.macdiv(fastperiod, slowperiod, trigperiod);
macdiv(MyStocks,fastperiod, slowperiod, trigperiod);
macdiv(MyStocks(iStock),fastperiod, slowperiod, trigperiod);
macdiv(Close,fastperiod, slowperiod, trigperiod);

Optional Arguments Default
fastperiod
13
slowperiod
26
trigperiod
9
Output Notes

If trigperiod is an explicit input argument, then the output
of macdiv contains a 2 column array. Otheriwse, a one
column vector or cell array is returned.

If trigperiod:

stockasset input:

mcd1 = MyStocks.macdiv(...);
mcd1 = macdiv(MyStocks,...);
mcd1{iStock} = [macdivline triggerline]

numeric array input:

mcd2 = macdiv(MyStocks(iStock),...);
mcd2 = macdiv([Close],...);
mcd2 = [macdivline triggerline]

 

Example

fastperiod = 13;
slowperiod = 26;
trigperiod = 9;
mcd1 = MyStocks.macdiv(fastperiod, slowperiod, trigperiod);

figure(1)
clf
indchart(MyStocks,mcd1{iStock}, 'centered', '3months')
xlabel('Date')
title('MACD','fontweight','bold')

image

back to top


N-Day Slope

Syntax

MyStocks.ndayslope(period);
ndayslope(MyStocks,period);
ndayslope(MyStocks(iStock),period);
ndayslope(Close,period);

Optional Arguments Default
period
5

 

Example

period = 5;
nds1 = MyStocks.ndayslope(period);

figure(1)
clf
indchart(MyStocks,nds1{iStock, 'centered', '3months')
xlabel('Date')
title('N-Day Slope','fontweight','bold')

image

back to top


Negative Volume Index

Syntax

MyStocks.nvindex(trigperiod);
nvindex(MyStocks, trigperiod);
nvindex(MyStocks(iStock), trigperiod);
nvindex([Close Volume], trigperiod);

Optional Arguments Default
trigperiod
50
Output Notes

If trigperiod is an explicit input argument, then the output
of nvindex contains a 2 column array. Otheriwse, a one
column vector or cell array is returned.

If trigperiod:

stockasset input:

nvindex1 = MyStocks.nvindex(...);
nvindex1 = nvindex(MyStocks,...);
nvindex1{iStock} = [nvindexline triggerline]

numeric array input:

nvindex2 = nvindex(MyStocks(iStock),...);
nvindex2 = nvindex([Close Volume],...);
nvindex2 = [nvindexline triggerline]

 

Example

trigperiod = 50;
nvi1 = MyStocks.nvindex(trigperiod);

figure(1)
clf
indchart(MyStocks,nvi1{iStock}, 'centered', '3months', 'histoff')
xlabel('Date')
title('Negative Volume Index','fontweight','bold')

image

back to top


On Balance Volume

Syntax

MyStocks.obvol;
obvol(MyStocks);
obvol(MyStocks(iStock));
obvol([Close Volume]);

Optional Arguments Default
none
NA

 

Example

obv1 = MyStocks.obvol;

figure(1)
clf
indchart(MyStocks,obv1{iStock}, 'centered', '3months')
xlabel('Date')
title('On Balance Volume','fontweight','bold')

image

back to top


Percent Price Oscillator

Syntax

MyStocks.pposc(fastperiod, slowperiod, trigperiod);
pposc(MyStocks,fastperiod, slowperiod, trigperiod);
pposc(MyStocks(iStock),fastperiod, slowperiod, trigperiod);
pposc(Close,fastperiod, slowperiod, trigperiod);

Optional Arguments Default
fastperiod
13
slowperiod
26
trigperiod
9
Output Notes

If trigperiod is an explicit input argument, then the output
of pposc contains a 2 column array. Otheriwse, a one
column vector or cell array is returned.

If trigperiod:

stockasset input:

pposc1 = MyStocks.pposc(...);
pposc1 = pposc(MyStocks,...);
pposc1{iStock} = [pposcline triggerline]

numeric array input:

pposc2 = pposc(MyStocks(iStock),...);
pposc2 = pposc([Close],...);
pposc2 = [pposcline triggerline]

 

Example

fastperiod = 13;
slowperiod = 26;
trigperiod = 9;
ppo1 = MyStocks.pposc(fastperiod, slowperiod, trigperiod);

figure(1)
clf
indchart(MyStocks,ppo1{iStock}, 'centered', '3months')
xlabel('Date')
title('Percent Price Oscillator','fontweight','bold')

image

back to top


Percent Volume Oscillator

Syntax

MyStocks.pvosc(fastperiod, slowperiod, trigperiod);
pvosc(MyStocks,fastperiod, slowperiod, trigperiod);
pvosc(MyStocks(iStock),fastperiod, slowperiod, trigperiod);
pvosc(Close,fastperiod, slowperiod, trigperiod);

Optional Arguments Default
fastperiod
13
slowperiod
26
trigperiod
9
Output Notes

If trigperiod is an explicit input argument, then the output
of pvosc contains a 2 column array. Otheriwse, a one
column vector or cell array is returned.

If trigperiod:

stockasset input:

pvosc1 = MyStocks.pvosc(...);
pvosc1 = pvosc(MyStocks,...);
pvosc1{iStock} = [pvoscline triggerline]

numeric array input:

pvosc2 = pvosc(MyStocks(iStock),...);
pvosc2 = pvosc([Close],...);
pvosc2 = [pvoscline triggerline]

 

Example

fastperiod = 13;
slowperiod = 26;
trigperiod = 9;
pvo1 = MyStocks.pvosc(fastperiod, slowperiod, trigperiod);

figure(1)
clf
indchart(MyStocks, pvo1{iStock}, 'centered', '3months')
xlabel('Date')
title('Percent Volume Oscillator','fontweight','bold')

image

back to top


Positive Volume Index

Syntax

MyStocks.pvindex(trigperiod);
pvindex(MyStocks,trigperiod);
pvindex(MyStocks(iStock),trigperiod);
pvindex([Close Volume],trigperiod);

Optional Arguments Default
trigperiod
50
Output Notes

If trigperiod is an explicit input argument, then the output
of pvindex contains a 2 column array. Otheriwse, a one
column vector or cell array is returned.

If trigperiod:

stockasset input:

pvindex1 = MyStocks.pvindex(...);
pvindex1 = pvindex(MyStocks,...);
pvindex1{iStock} = [pvindexline triggerline]

numeric array input:

pvindex2 = pvindex(MyStocks(iStock),...);
pvindex2 = pvindex([Close Volume],...);
pvindex2 = [pvindexline triggerline]

 

Example

trigperiod = 50;
pvi1 = MyStocks.pvindex(trigperiod);

figure(1)
clf
indchart(MyStocks, pvi1{iStock}, 'centered', '3months', 'histoff')
xlabel('Date')
title('Positive Volume Index','fontweight','bold')

image

back to top


Price and Volume Trend

Syntax

MyStocks.pvtrend;
pvtrend(MyStocks);
pvtrend(MyStocks(iStock));
pvtrend([Close Volume]);

Optional Arguments Default
none
NA

 

Example

pvt1 = MyStocks.pvtrend;

figure(1)
clf
indchart(MyStocks, pvt1{iStock}, 'centered', '3months')
xlabel('Date')
title('Price and Volume Trend','fontweight','bold')

image

back to top


Rate of Change

Syntax

MyStocks.rateofchange(period);
rateofchange(MyStocks,period);
rateofchange(MyStocks(iStock),period);
rateofchange(Close,period);

Optional Arguments Default
period
12

 

Example

period = 12;
roc1 = MyStocks.rateofchange(period);

figure(1)
clf
indchart(MyStocks, roc1{iStock}, 'centered', '3months')
xlabel('Date')
title('Rate of Change','fontweight','bold')

image

back to top


Volume Weighted MACD

Syntax

MyStocks.macdiv(fastperiod, slowperiod, trigperiod);
vwmacdiv(MyStocks,fastperiod, slowperiod, trigperiod);
vwmacdiv(MyStocks(iStock),fastperiod, slowperiod, trigperiod);
vwmacdiv([Close Volume],fastperiod, slowperiod, trigperiod);

Optional Arguments Default
fastperiod
13
slowperiod
26
trigperiod
9
Output Notes

If trigperiod is an explicit input argument, then the output of
vwmacdiv
contains a 2 column array. Otheriwse, a one column
vector or cell array is returned.

If trigperiod:

stockasset input:

vwmcd1 = MyStocks.vwmacdiv(...);
vwmcd1 = vwmacdiv(MyStocks,...);
vwmcd1{iStock} = [vwmcdline triggerline]

numeric array input:

vwmcd2 = vwmacdiv(MyStocks(iStock),...);
vwmcd2 = vwmacdiv([Close Volume],...);
vwmcd2 = [vwmcdline triggerline]

 

Example

fastperiod = 13;
slowperiod = 26;
trigperiod = 9;
vwmcd1 = MyStocks.macdiv(fastperiod, slowperiod, trigperiod);

figure(1)
clf
indchart(MyStocks,vwmcd1{iStock}, 'centered', '3months')
xlabel('Date')
title('Volume Weighted MACD','fontweight','bold')

image

back to top


Williams Accumulation/Distribution

Syntax

MyStocks.williamsad;
williamsad(MyStocks);
williamsad(MyStocks(iStock));
williamsad([High Low Close]);

Optional Arguments Default
none
NA

 

Example

figure(1)
clf
indchart(MyStocks, wad1{iStock}, 'centered', '3months')
xlabel('Date')
title('Williams Accumulation/Distribution','fontweight','bold')

image

back to top

Banded Indicators

Money Flow Index

Syntax

MyStocks.mfindex(period);
mfindex(MyStocks,period);
mfindex(MyStocks(iStock),period);
mfindex([High Low Close Volume],period);

Optional Arguments Default
period
14

 

Example

period = 14;
mfi1 = MyStocks.mfindex(period);

figure(1)
clf
indchart(MyStocks,mfi1{iStock}, 'banded', [20 80], '3months')
xlabel('Date')
title('Money Flow Index','fontweight','bold')

image

back to top


Relative Strength Index

Syntax

MyStocks.rsindex(period);
rsindex(MyStocks,period);
rsindex(MyStocks(iStock),period);
rsindex(Close,period);

Optional Arguments Default
period
14

 

Example

period = 14;
rsi1 = MyStocks.rsindex(period);

figure(1)
clf
indchart(MyStocks,rsi1{iStock}, 'banded', [30 70], '3months')
xlabel('Date')
title('Relative Strength Index','fontweight','bold')

image

back to top


Stochastic Oscillator

Syntax

MyStocks.fullstochosc(highlowperiod,slowKperiod,slowDperiod);
fullstochosc(MyStocks,highlowperiod,slowKperiod,slowDperiod);
fullstochosc(MyStocks(iStock),highlowperiod,slowKperiod,slowDperiod);
fullstochosc([High Low Close],highlowperiod,slowKperiod,slowDperiod);

Optional Arguments Default
highlowperiod
14
slowKperiod
3
slowDperiod
3
Output Notes

The output of the fullstochastic function contains a 4 column array as follows:

stockasset input:

stoch1 = MyStocks.fullstochosc(...);
stoch1 = fullstochosc(MyStocks,...);
stoch1{iStock} = [fastK fastD slowK slowD]

numeric array input:

stoch2 = fullstochosc(MyStocks(iStock),...);
stoch2 = fullstochosc([High Low Close],...);
stoch2 = [fastK fastD slowK slowD]

 

Example

highlowperiod = 14;
slowKperiod = 3;
slowDperiod = 3;
stoch1 = MyStocks.fullstochosc(highlowperiod,slowKperiod,slowDperiod);

figure(1)
clf
indchart(MyStocks, stoch1{1}(:,[1 2]), 'banded', [20 80], '3months')
xlabel('Date')
title('Fast Stochastics','fontweight','bold')

image

figure(1)
clf
indchart(MyStocks, stoch1{1}(:,[3 4]), 'banded', [20 80], '3months')
xlabel('Date')
title('Slow Stochastics','fontweight','bold')

image

back to top


Williams %R

Syntax

MyStocks.williamspctr(period);
williamspctr(MyStocks,period);
williamspctr(MyStocks(iStock),period);
williamspctr([High Low Close],period);

Optional Arguments Default
period
14

 

Example

wpr1 = MyStocks.williamspctr(period);

figure(1)
clf
indchart(MyStocks, wpr1{iStock}, 'banded', [-80 -20], '3months')
xlabel('Date')
title('Williams %R','fontweight','bold')

image

back to top