By Shivgan Joshi Qcfinance.in Technical Analysis using MATLAB using Financial Time Series Focus on Moving average and Bollinger Bands By Shivgan Joshi Qcfinance.in
Caution MATLAB is case sensitive
Difference formats to get data in the FTS Object From CSV From file directly From the .dat file Using ascii2fints carefully by specifying the right parameters
Input CSV – Method 1 filename = 'csvlist.dat'; M = csvread(filename) Make sure it is numeric format Then create fts object from matrices http://in.mathworks.com/help/matlab/ref/csvr ead.html
Inputting Data .dat are tab delimited data which can be saved using excel txt save myinc = ascii2fts('input.dat'); An alternative is the load command to bring all variables from a file into the current variables ASCII2FTS is an important conversion function http://in.mathworks.com/help/finance/ascii2fts.ht ml http://in.mathworks.com/help/finance/technical- analysis-examples.html
Code Part 1 Use GUI to import the FTS Things work with the close price so all other prices don’t 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.') csvwrite('csvlist.dat',input)
Saving output http://in.mathworks.com/help/matlab/ref/csvw rite.html
Playing with matrix Logic including count, for and if to extract the data
[input_Mid,input_Uppr,input_Lowr]= bollinger(candle); tsmat = fts2mat(tsobj)