Technical Analysis using MATLAB
using Financial Time Series
Focus on Moving average and
Bollinger Bands
By Shivgan Joshi
[Link]
Caution
MATLAB is case sensitive
Difference formats to get data in the FTS
Object
1. From CSV
2. From file directly
3. From the .dat file
. Using ascii2fints carefully by specifying the right
parameters
Input CSV Method 1
filename = '[Link]'; M = csvread(filename)
Make sure it is numeric format
Then create fts object from matrices
[Link]
[Link]
Inputting Data
.dat are tab delimited data which can be saved using
excel txt save
myinc = ascii2fts('[Link]');
An alternative is the load command to bring all
variables from a file into the current variables
ASCII2FTS is an important conversion function
[Link]
ml
[Link]
Code Part 1
Use GUI to import the FTS
Things work with the close price so all other
prices dont matter
macd_input = macd(input);
Code for Moving average of the data
subplot(2, 1, 1);
plot(macd_input);
title('MACD of Input Close Stock Prices,
10/01/95-12/31/95');
datetick('x', 'mm/dd/yy');
subplot(2, 1, 2);
highlow(part_input);
title('IBM Stock Prices, 10/01/95-12/31/95');
datetick('x', 'mm/dd/yy')
Bollinger Band on the Data
[input_Mid,input_Uppr,input_Lowr]=
bollinger(myinc);
input_CloseBolling = [input_Mid.CLOSE,
input_Uppr.CLOSE,...
input_Lowr.CLOSE];
plot(input_CloseBolling)
title('Bollinger Bands for inputney Closing
Prices')
Cleaning and Exporting Data
Count rows and columns of matrix
[rows columns] = size(input)
for a = 1:rows
Input(a,2)
end
if input(2,a)>100
disp('Value within specified range.')
end
csvwrite('[Link]',input)
[Link]
Saving output
[Link]
[Link]
Playing with matrix
Logic including count, for and if to extract the
data
[input_Mid,input_Uppr,input_Lowr]=
bollinger(candle);
tsmat = fts2mat(tsobj)
Tasks
candle excel sheet
Bollinger code
3d plotting
Candle Sticks
Body nature
DOJI
HAMMER
HANGING MAN
Inverted Hammer
Shooting star
[Link]
html;jsessionid=12076760ee3791f11ef00890ed8e
Matrix of Strings in MATLAB
[Link]
how-can-i-fill-a-matrix-dynamically-withstrings-in-matlab
3D Charts
Heatmaps and 3D charts
Charting fundamentals
Matrix format
[Link]
[Link]
[Link]
[Link]
Revising Financial Toolbox
PV FV
Portfolio Toolboxx
Regression
Fixed income standards
Mesh