It is believed that candlestick charts originated in Japan in the 18th century as a form of visual analysis for rice traders. The chart shows the market’s open, high, low, and close prices for each time period (usually for a trading day). Using different colours, the chart shows the size of price moves (rising or falling prices). It also helps to make trading decisions based on the repetition of patterns that in turn help to forecast the short-term direction of the price. Today candlestick charts are mostly used to visualise price changes for a stock or currency.
Before learning how to create the candlestick chart in Tableau, let’s look at how to read one. The central coloured part is called the ‘body’ and shows the open and closing prices for the trading day. The ‘body’ is usually shaded red if the closing prices are below opening prices, and green when closing prices are above the opening ones. The thin vertical lines that go through the ‘body’ of the chart are usually called ‘tails’ or ‘wicks’ and show the high and low values reached within the trading day. In the tutorial below, I chose red and grey to make the chart colour blind-friendly.
To build the chart below I’m using Kaggle’s historical price data for the 500 largest companies (S&P 500).
1 – Let’s start by placing the [date] field to the Columns shelf and the [low] field to the Rows shelf. To change the date level to daily, either click on the [date] field once it is on the Columns shelf and select the “Day – May 8, 2015” option. Alternatively, hold both mouse buttons when dragging the field to the shelf, and select the relevant date level in the dialogue box that appears once the field is on the shelf.
2 – Filter the view to see only prices for one company, for example for Apple Inc., by dragging the [symbol] field to the Filters shelf and selecting “AAPL”. To see daily changes, filter the view to a smaller period, for example a month, by dragging the [date] field to the Filters shelf and selecting a range of dates you are interested in from the dialogue box that appears. In my case, I filtered for the period between 15 September – 1 November 2011.
3 – Now drag the [high] field to the Rows shelf and place it next to the [open] field. Then click on the [high] field and select the “Dual Axis” option from the drop-down menu. Remember to synchronise the axes for these two charts by clicking on an axis for any of the measures and select the “Synchronise axis” option from the drop-down menu.
4 – To have a better view of price changes during the selected period, double-click on the [low] axis header and uncheck “Include zero” option in the appeared dialogue box.
5 – Change the chart type to Gantt Bar and you should have something similar to this chart below:
6 – Next we would need to create two calculated fields:
Difference between High and Low prices
Difference between the Close and Open prices
7 – Now let’s add these fields to the Marks card for the relevant charts:
- Drag the [Difference between the Close and Open prices] field to the Colour and Size cards for the SUM(open) chart. Click on the Colour card and change the palette settings to “Stepped Color” with 2 steps.
- Drag the [Difference between High and Low prices] field to the Size card for the SUM(low) chart. Click on the Size card and decrease the size of the chart to the minimum.
At this point you should have the completed candlestick chart as below: