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 !

 Réponse acceptée

Stephan
Stephan le 18 Fév 2019
Modifié(e) : Stephan le 18 Fév 2019

0 votes

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 commentaires

Ning Ji
Ning Ji le 18 Fév 2019
Modifié(e) : Ning Ji le 18 Fév 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 !
Stephan
Stephan le 18 Fév 2019
Could you attach your .csv-file?
Ning Ji
Ning Ji le 18 Fév 2019
Attached, it's the standard one from yahoo site. Thanks !
Stephan
Stephan le 18 Fév 2019
Modifié(e) : Stephan le 18 Fév 2019
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 le 18 Fév 2019
Modifié(e) : Ning Ji le 18 Fév 2019
cool, it starts to working now.
It's a great example for python developers.
Many thanks !

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Import and Export dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by