Hi,
In this post, I will describe about how to plot candle chart from historical data.
I will plot the data in the struct json2data.candleStick
>> response = POLO_ChartData(pair, starttime, endtime, period);
json2data = loadjson(response);
>> json2data
json2data =
struct:
candleStick: {1×1087 cell}
range: 7819200
First, we need to count the number of candle stick using length() command.
Also, we need to define vectors to store each value.
nCandle = length(json2data.candleStick);
dateVal = zeros(nCandle,1);
highVal = zeros(nCandle,1);
lowVal = zeros(nCandle,1);
closeVal = zeros(nCandle,1);
openVal = zeros(nCandle,1);
Using for loop, we collect all data to desired variables.
Also, we define new struct called candleChart for convinience.
for i = 1:nCandle
closeVal(i) = json2data.candleStick{i}.close;
openVal(i) = json2data.candleStick{i}.open;
highVal(i) = json2data.candleStick{i}.high;
lowVal(i) = json2data.candleStick{i}.low;
dateVal(i) = datenum([1970 1 1 0 0 json2data.candleStick{i}.date]);
end
candleChart.date = dateVal;
candleChart.high = highVal;
candleChart.low = lowVal;
candleChart.close = closeVal;
candleChart.open = openVal;
candleChart.ntime = nCandle;
candleChart.period = period;
candleChart.pair = pair;
MATLAB provides nice function called candle() to plot candle chart.
You could call following code.
candle(candleChart.high, candleChart.low, candleChart.close, ...
candleChart.open, 'b', candleChart.date,'dd-mmm');
title('BTC XMR');
ylabel('satoshi');
And you may get chart as below:
Of course, MATLAB financial toolbox provides fints
which is financial time series object.
However, I'm not familiar to the object yet.
Just get to the machine learning lessons already! :P
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congrats! You've made a step forward for future tech!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
What do you mean "candle chart"? Can you explain it more in detail? and what is advantage of this candle chart?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Trading orders are kind of continuous time discrete event. So we may need a lot of data to represent the all order history.
Candle chart is a way of compacting the order history, in such a way that for a certain time (say from 1:00~2:00 am), we record most expensive price, cheapest price and open, close price and trading volume within the time.
There are other kinds of chart such as bar chart or - * chart but nowadays candle chart is most popular.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @algorithmtrader! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit