Creating a Candlestick Chart in Tableau

Maxwell Bosse
5 min readJan 25, 2021

--

As a new user of Tableau Public I wanted to experiment with different ways I could use the platform to visualize stock data. One of the most informative and helpful ways to visualize time series data for a stock is with a candle stick chart.

source: http://www.chart-formations.com/stock-charts/candlestick-charts.aspx

A candle stick chart offers an informative view of stock time series data in that each candlestick provides us with the stocks opening price, closing price, high price and low price for the interval we are examining (for this blog we will go with daily). Additionally the color of the bar tells us whether the stock closed higher than it opened or not (green if closed higher than it opened, red if closed lower than it opened).

source: https://www.warriortrading.com/how-to-read-candlestick-charts/

Creating a Candlestick Chart in Tableau

Step 1 — Get the time series data for the stock of interest. The AlphaVantage API is a great resource for getting time series data. Once you get the time series data downloaded to a CSV we can get started in Tableau.

Step 2 — Open Tableau public desktop app and upload our CSV by clicking “Connect to Data” in the top left of the window and selecting the CSV file.

Step 3 — With our data loaded go to Sheet 1 at the bottom of the window and drag the Date field to the Column Shelf as shown below. Given that we are doing a Daily candlestick chart, click into the Date field (click the upside down triangle to open) and select “Day” from the second group of intervals. Also make sure that you have “Discrete” selected, not continuous.

Step 4 — Again, we are going to grab the Date field and this time drag it to the Filters window. Here we will select the Relative Dates field and select the timeframe we would like to visualize. We will view the last 30 days in this example.

Step 5 — Now we are going to take two measures of interest (Open, Close, High, Low) to the Rows Shelf. Make sure to take one from High and Low and one from Open and Close. I will take High and Open in this example. Here we will click into one of the fields and select Dual-Axis. This will combine our two measures into one graph.

Step 6 — In the Marks field, we will change the mark type from Automatic (the default) to Gantt Bar.

Step 7 — Now we need to create two new measures. The first will be our Line which is the difference between the High Price and the Low Price. The second will be our candlestick which is the difference between our Open Price and Close Price. To do this we need to click into “Create Calculated Field” above the tables pane and create both the above calculations. Pictured below is the Line calculation which is the same format as the Candlestick calculation.

Step 8 — Formatting our line. Here we will click into our Sum(High) Mark and remove the “Measure Values” field by dragging it to any gray space on the screen and dropping it. Then we will click into the colors field and select black. Lastly we will drag our newly created “Line” calculated measure to the size field. Here we will drag the size slider to the far left. The result is seen below.

Step 9— Formatting our candlestick. Here we will click into our Sum(Open) Mark and remove the “Measure Values” field by dragging it to any gray space on the screen and dropping it. Then we will drag our newly created “Candlestick” calculated measure to the size field AND to the color field. We will then click the color field, select edit colors, and select the Red-Green Diverging palette from the drop-down menu. We will also select “Stepped Color” and set it to 2 steps so we either have a green bar or red bar and nothing in between.

Step 10 — Lastly, we can right click our y-axis on the left and select “Synchronize Axis”. If you would like to rescale the axis you can also click “Edit Axis” and under range you can unselect the “include zero” box. This is advised when the stock you are looking at is priced well-above zero.

Result

--

--