Overlays - Technical Analysis Toolbox™
Overlays

Several overlay functions are detailed below. Overlays are usually plotted over price data. These overlay functions allow you the freedom to examine the data as you wish.

Contents

Functions

Examples

back to top

Functions

Function List

Function Description
bollingerbands Bollinger Bands
fiblines Fibonacci Retracement Lines
keltnerchannels Keltner Channels
mavg Moving Averages
pricechannel Price Channels
typrice Typical Price

back to top


Global Syntax

All indicator and overlay functions have the same core syntax. This syntax is described in detail in the indicators help section here.

See: Global Syntax

back to top

Examples

Bollinger Bands

Syntax

MyStocks.bollingerbands(smaperiod,nstd);
bollingerbands(MyStocks,smaperiod,nstd);
bollingerbands(MyStocks(iStock),smaperiod,nstd);
bollingerbands(Close,smaperiod,nstd);

Optional Arguments Default
smaperiod
20
nstd
2.0
Output Notes

The output of the bollingerbands function contains a 3 column array is as follows:

stockasset input:

bbands1 = MyStocks.bollingerbands(...);
bbands1 = bollingerbands(MyStocks,...);
bbands1{iStock} = [simplemovavg upperband lowerband]

numeric array input:

bbands2 = bollingerbands(MyStocks(iStock),...);
bbands2 = bollingerbands([High Low Close],...);
bbands2 = [simplemovavg upperband lowerband]

 

Example

smaperiod = 20;
nstd = 2;
bbands1 = MyStocks.bollingerbands(smaperiod,nstd);
coptions = chartoptions('candle', 3months');
figure(1)
clf
hgroup = stockchart(MyStocks(iStock),coptions);
addoverlay(hgroup,bbands1{iStock}, 'BBands(20,2)')
xlabel(hgroup(end), 'Date')
title('Bollinger Bands','fontweight','bold')

image

back to top


Fibonacci Retracement Lines

Syntax

fline1 = MyStocks.fiblines(period);
fline2 = fiblines(MyStocks,period);
fline3 = fiblines(MyStocks(iStock),period);
fline4 = fiblines([High Low],period);

Optional Arguments Default
period
20
Output Notes

The fiblines function returns a 5 column array corresponding
to the levels: [0% 38.2% 50% 61.8% 100%].
These levels indicate the percent level between the lowest low
and the highest high over the period.
The 5 column array output of the fiblines function is as follows:

stockasset input:

bbands1 = MyStocks.bollingerbands(...);
bbands1 = bollingerbands(MyStocks,...);
bbands1{iStock} = [simplemovavg upperband lowerband]

numeric array input:

bbands2 = bollingerbands(MyStocks(iStock),...);
bbands2 = bollingerbands([High Low],...);
bbands2 = [simplemovavg upperband lowerband]

 

Example

period = 20;
fline1 = MyStocks.fiblines(period);

coptions = chartoptions('candle', 3months');
figure(1)
clf
hgroup = stockchart(MyStocks(iStock),coptions);
addoverlay(hgroup,fline1{iStock}, 'Fibonccai(20)')
xlabel(hgroup(end), 'Date')
title('Fibonacci Retracement','fontweight','bold')

image

back to top


Keltner Channels

Syntax

MyStocks.keltnerchannels(emaperiod,natr,atrperiod);
keltnerchannels(MyStocks,emaperiod,natr,atrperiod);
keltnerchannels(MyStocks(iStock),emaperiod,natr,atrperiod);
keltnerchannels([High Low Close],emaperiod,natr,atrperiod);

Optional Arguments Default
emaperiod
20
natr
2.0
atrperiod
10
Output Notes

The output of the keltnerchannels function contains a 3 column array as follows:

stockasset input:

kchan1 = MyStocks.keltnerchannels(...);
kchan1 = keltnerchannels(MyStocks,...);
kchan1{iStock} = [expmovavg upperband lowerband]

numeric array input:

kchan2 = keltnerchannels(MyStocks(iStock),...);
kchan2 = keltnerchannels([High Low Close],...);
kchan2 = [expmovavg upperband lowerband]

 

Example

emaperiod = 20;
natr = 2.0;
atrperiod = 10;
kchan1 = MyStocks.keltnerchannels(emaperiod,natr,atrperiod);

coptions = chartoptions('candle', '3months');
figure(1)
clf
hgroup = stockchart(MyStocks(iStock),coptions);
addoverlay(hgroup,kchan1{iStock}, 'KChannels(20,2.0,10)')
xlabel(hgroup(end), 'Date')
title('Keltner Channels','fontweight','bold')

image

back to top


Moving Averages

Syntax

MyStocks.mavg(period, matype);
mavg(MyStocks,period, matype);
mavg(MyStocks(iStock),period, matype);
mavg(Close,period, matype);
mavg([Close Volume],period, [matype = 'vwma']);

Optional Arguments Default
period
20
matype
'ema'
Syntax Notes

The following moving average types are supported:
'sma': simple moving average
'ema': exponential moving average
'wma': weighted moving average
'vwma': volume weighted moving average

 

Example

period = 20;
ma1 = MyStocks.mavg(period, 'ema');

coptions = chartoptions('candle', 3months');
figure(1)
clf
hgroup = stockchart(MyStocks(iStock),coptions);
ha = addoverlay(hgroup,MyStocks(iStock).mavg(5,'ema'),'ema(5)');
set(ha,'color',[0 0 1])
ha = addoverlay(hgroup,MyStocks(iStock).mavg(20,'ema'),'ema(20)');
set(ha,'color',[1 0 0])
xlabel(hgroup(end), 'Date')
title('Exponential Moving Average', 'fontweight', 'bold')

image

back to top


Price Channels

Syntax

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

Optional Arguments Default
period
20
Output Notes

The output of the pricechannel function contains a 2 column array as follows:

stockasset input:

prchannel1 = MyStocks.pricechannel(...);
prchannel1 = pricechannel(MyStocks,...);
prchannel1{iStock} = [upperchannel lowerchannel]

numeric array input:

prchannel2 = pricechannel(MyStocks(iStock),...);
prchannel2 = pricechannel([High Low],...);
prchannel2 = [upperchannel lowerchannel]

 

Example

period = 20;
prchannel1 = MyStocks.pricechannel(period);

coptions = chartoptions('candle', 3months');
figure(1)
clf
hgroup = stockchart(MyStocks(iStock),coptions);
addoverlay(hgroup,prchannel1{iStock}, 'PriceChannels(20)')
xlabel(hgroup(end), 'Date')
title('Price Channels', 'fontweight', 'bold')

image

back to top


Typical Price

Syntax

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

Optional Arguments Default
none
NA

 

Example

typ1 = MyStocks.typrice;

coptions = chartoptions('candle', 3months');
figure(1)
clf
hgroup = stockchart(MyStocks(iStock),coptions);
addoverlay(hgroup,typ1{iStock}, 'TypPrice')
xlabel(hgroup(end), 'Date')
title('Typical Price', 'fontweight', 'bold')

image

back to top