Looking for candlestick, rsi, csv file example

Normally for python and other languages, if i search such keywords candlestick+rsi+csv, i can find plenty of examples.
Now i'm learning matlab, cannot find proper samples yet, so want to start with dummy questions, pls bear with me.
i got this:
Data = readtable('/home/usr1/matlab/spy.csv')
now i want to draw the candlestick and rsi in the same figure, can someone show me a simple code to get started ?
My question is, i don't know the latest correct ways, some examples are from 2011 and won't compile in the latest matlab version.
Thanks !

 Accepted Answer

Stephan
Stephan on 18 Feb 2019
Edited: Stephan on 18 Feb 2019
Hi,
here is a working example for candlestick containing .csv-data which works on R2018b:
Based on this code, the data and the Documentation of RSI it should be easy to plot the RSI.
Best regards
Stephan

5 Comments

Ning Ji
Ning Ji on 18 Feb 2019
Edited: Ning Ji on 18 Feb 2019
Thanks Stephan,
i did try that before asking this question, i pretty much copied everything, just changed to read qqq.csv which i downloaded from yahoo.
>> matlabroot
ans =
'/usr/local/MATLAB/R2018b'
>> c5
Warning: Variable names were modified to make them valid MATLAB identifiers. The
original names are saved in the VariableDescriptions property.
Error using tabular/mergevars (line 65)
Unable to merge specified variables because they have different data types.
Consider setting 'MergeAsTable' to true.
Error in c5 (line 2)
Data = mergevars(Data,[1 2]);
The general question, besides the readtable(), i saw csvread(), so not sure which one should use in the long run. I'm looking for a most updated places to get started with finance toolkit given l'm new to these.
Thanks !
Could you attach your .csv-file?
Attached, it's the standard one from yahoo site. Thanks !
The warning appears since there is a space in Adj Close, which is an unallowed variable name. I used the HeaderLines',1 which fixes the problem and gave the variable names by hand:
Data = readtable('qqq.csv','HeaderLines',1);
Data.Properties.VariableNames = {'Date_Time', 'Open', 'High', 'Low',...
'Close', 'Adj_Close', 'Volume'};
Data = table2timetable(Data);
candle(Data)
I think this is a pretty nice short code to get a candlestick chart...
Ning Ji
Ning Ji on 18 Feb 2019
Edited: Ning Ji on 18 Feb 2019
cool, it starts to working now.
It's a great example for python developers.
Many thanks !

Sign in to comment.

More Answers (0)

Tags

Asked:

on 18 Feb 2019

Edited:

on 18 Feb 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!