OHLC Series
Overview
An open-high-low-close chart (also known as OHLC, HLOC chart) is a type of chart typically used to illustrate movements in the price of a financial instrument over time. Each vertical line on the chart shows the price range (the highest and lowest prices) over one unit of time, e.g. one day or one hour. Tick marks project from each side of the line indicating the opening price (e.g. for a daily bar chart this would be the starting price for that day) on the left, and the closing price for that time period on the right. The bars may be shown in different hues depending on whether prices rose or fell in that period.
Adding OHLC Series
Data-Provider
Before you can add OHLC series to the chart you need to prepare Data Provider. You need four fields to create OHLC chart: open, high, low and close. So the Data Provider should contain all these four fields.
Sample XML for OHLC Data Provider:
As you can see four fields are defined open, high, low and close. Now you can declare series that will use this Data Provider.
Series Declaration
XML syntax to declare series with Data Provider shown above:
Let's put this together and create the very basic OHLC sample:
To learn more about common series settings see Common Series Settings tutorial.
Configuring visualization
All visual and specific settings for OHLC series are set in <ohlc_series> in <series> node.
The width of OHLC is set using width attribute: <ohlc_series width="0.5">, which accepts values from 0 to 1.
Also, you can tune different OHLC visualization depending on rise or fall of the price. These settings are done in <rising>, and <falling> nodes.
Sample XML with width and and different visualization for rise and fall:
Live Sample below shows to charts with different OHLC series, each with own specific settings:
Live Sample: OHLC Series Visual Settings
To learn more about all available settings about visual settings see respective nodes in XML Reference.
Legend Element
For each series you can define its element in legend. This element contains the settings for the formatting string of the text in legend that represents the series. Configuration of such elements is described in Legend: Series Labels article.
Tooltips
You can either use global tooltip settings or create personal tooltips for each series. See detailed description in Tooltips tutorial.
Choosing Field for Comparison Mode
When you use OHLC series in comparison mode (when Value axis is set to "Changes" or "PercentChanges") - you need to define comparison field.
XML for comparison mode field selection:
As you can see comparison field is set in compare_field_type attribute, which can: Open, High, Low and Close. By default it is Close.
Live sample below shows OHLC and Line series on one chart in Comparison mode with comparison field set to Open:
Live Sample: OHLC Series In Comparision Mode
Defaults Section
There is a special section to set default values in AnyChart Stock component XML:
<series_settings>, where you can define marker and value highlighter settings for all series of the given type
in one place, instead of setting them for each series individually.
For example, to configure all series of OHLC type just set:
07 | color: "DarkColor(%Color)" , |
13 | color: "LightColor(%Color)" , |
Live sample below has two series of Candlestick type. All common settings defined in <series_settings_defaults/> node :
Live Sample: OHLC Series - Using Defaults Sections