How to Create an OHLC Chart

Table of Contents

What is an OHLC Chart

OHLC or Open-High-Low-Close stock charts are used to track price movements and help making decisions on purchasing stock. They are similar and provide an alternative view to the Candlestick charts. Each entry may show a stock price variation within a period of one day, month, quarter or year.

Each vertical extremities represents the high to low during the period. The small left stick is the opening price, and the small right stick the closing price.

Remark that high is always on top, but open and close may switch places. With close above open, we have a rising price, and we may use the up color. With close below open, the falling price may be displayed with the down color.

Steps to Create an OHLC Chart

Start Visual Xtractor or Data Xtractor. Connect to a database. Create or design a SQL query. Run the query and check the results.

  1. Display and enable the Chart query builder.
  2. For your opening and closing price values, use the Stock ChartsStock Open and/or Stock Close selections. You may skip one of them and set the Auto Open or Close option. You may assign each of them once only.
  3. For your low and high price values, use the Stock ChartsStock Low and/or Stock High selections. You may skip both, and use them once only.
  4. In the Stock Chart Options toolbar button, make sure the OHLC is selected.
  5. Select one datetime column as chart Label. When omitted, a series of 1, 2, 3 etc will be automatically generated for the horizontal X time axis.
  6. You may also add an Area chart at the bottom with Volume values.
  7. Or you may add a Bollinger Band chart (as a Range Spline Area) in the background.

OHLC Chart Demo Query

This is a great alternative to learn about and play with this type of chart, if you don’t want to create it from scratch.

Look for the ready-to-use single-series OHLC Chart generated query under the Queries > Demo Queries > Charts > Stock Charts folder. Click on the “add demo queries” command link, if not already there.

The generated demo queries must work for any database, with no restriction. They use constant values generated on-the-fly and your database SQL engine, but do not depend on data from your tables, and never alter your database in any way.

HLC Chart

As its name suggests, the Stock Open column is missing, in which case it’s customary to extend the small right stick of the closing values on the other side, as in a cross.

The HLC Chart demo query shows a typical High-Low-Close stock chart, with no Stock Open column.

OHLC Chart with no Open or Close

While the opening price of one day is usually the same as the closing price of the previous day, you may omit either Open or Close, and check the Auto Open or Close toolbar option to automatically determine the missing value.

For instance, the OHLC chart below has the Open values determined from the Close values, and it looks almost identical to the first complete OHLC chart. Remark this is not a HLC chart, as long as the opening values are still transparently provided.

OHLC with Auto Open

The Auto-Fill Open-Close Chart demo query shows a Candlestick or OHLC stock chart with either Open or Close missing.

Did You KnowA chart type with both Open and Close missing, with only Low and High, is also possible, but this is no longer an OHLC chart.

The resulting chart is actually called High-Low (or HiLo) chart and described separately, as it is more generic.

OHLC Chart with no Low and High

When Low and High are both omitted, we look at an Open-Close (OC) chart, i.e. an OHLC chart that looks more like a continuous Step Line chart. Low and High values are not essential to draw an OHLC chart, but other charting libraries always expect them, we don’t.

Open-Close Chart
The Open-Close Chart demo query shows an OHLC stock chart with no Low and High.

OHLC Chart with Volume

It is customary to sometimes show below a stock chart a synchronized Volume Area chart. By default, it will be semi-transparent:

OHLC with Volume
The Stock with Volume demo query shows a Candlestick or OHLC stock chart with a Volume Area chart at the bottom.

OHLC Chart with Bollinger Band

On a stock chart you may also add a synchronized Bollinger Band chart in the background. It will be semi-transparent Range Spline Area and assigned to an empty or newly added last column.

OHLC with Bollinger Band
The Stock with Bollinger Band demo query shows a Candlestick or OHLC stock chart with a Bollinger Band chart on the background.

Customize your OHLC Chart

The chart toolbar at the bottom has many options you may change with one single click, to alter the graph. Here is just an example of what you can further do with this type of chart:

  1. Remove the up-and-down colors, to make the graph monochrome.
  2. Show data labels and the graph alone.

Custom OHLC Chart


  • Creating OHLC charts in Data Xtractor or Visual Xtractor is fast, intuitive and versatile: set your price/stock data columns as Stock Open, Stock Close, Stock Low and Stock High (not all columns required!), and one optional datetime column as Label.
  • Make sure your stock chart is rendered as OHLC, and not Candlesticks.
  • Add also a Volume Area chart at the bottom, or a Bollinger Band in the background.
  • Render the chart with optional Low and High values, as Open-Close chart.
  • Use previous Open/Close values to automatically determine the next Close/Open values, when one of them is not present.
  • Or skip completely the Open values, for a traditional HLC chart.
  • Many builtin powerful features of these chart type are common to most other charts: filtering series through the legend items, interactivity, monochrome or grayscale colors etc.
  • Switch to another builtin chart theme, or customize your own, for any possible color or other styles.