Skip to main content
Version: Java (Groovy)

ohlcPlot

The ohlcPlot method creates open, high, low, close (OHLC) plots using data from tables.

Syntax

ohlcPlot(seriesName, t, time, open, high, low, close)
ohlcPlot(seriesName, time, open high, low, close)
ohlcPlot(seriesName, sds, time, open, high, low, close)
ohlcPlot(seriesName, t, time, open, high, low, close)

Parameters

ParameterTypeDescription
seriesNameString

The name you want to use to identify the series on the plot itself.

ttable

The table that holds the data to be plotted.

sdsSelectableDataSet

A selectable data set (e.g., OneClick filterable table).

timeString

Column in t or sds that holds time data.

timeIndexableNumericData

Time data.

timeDateTime

Time data.

timeDate

Time data.

openString

The column in t or sds that contains the open data.

openIndexableNumericData

Open data.

opendouble[]

Open data.

openfloat[]

Open data.

openint[]

Open data.

openlong[]

Open data.

openshort[]

Open data.

openList<T>

Open data.

open<T>[]

Open data.

highString

The column in t or sds that contains the high data.

highIndexableNumericData

High data.

highdouble[]

High data.

highfloat[]

High data.

highint[]

High data.

highlong[]

High data.

highshort[]

High data.

highList<T>

High data.

high<T>[]

High data.

lowString

The column in t or sds that contains the low data.

lowIndexableNumericData

Low data.

lowdouble[]

Low data.

lowfloat[]

Low data.

lowint[]

Low data.

lowlong[]

Low data.

lowshort[]

Low data.

lowList<T>

Low data.

low<T>[]

Low data.

closeString

The column in t or sds that contains the close data.

closeIndexableNumericData

Close data.

closedouble[]

Close data.

closefloat[]

Close data.

closeint[]

Close data.

closelong[]

Close data.

closeshort[]

Close data.

closeList<T>

Close data.

close<T>[]

Close data.

Returns

An open, high, low, close (OHLC) plot with a single axes.

Examples

The following example plots data from a Deephaven table.

import static io.deephaven.csv.CsvTools.readCsv
import static io.deephaven.api.agg.Aggregation.AggAvg

cryptoTrades = readCsv("https://media.githubusercontent.com/media/deephaven/examples/main/CryptoCurrencyHistory/CSV/CryptoTrades_20210922.csv")

agg_list = [
AggLast("CloseTime = Timestamp"),\
AggFirst("OpenTime = Timestamp"),\
AggMax("High = Price"),\
AggMin("Low = Price"),
]

btcBin = cryptoTrades.where("Instrument=`BTC/USD`").update("TimestampBin = lowerBin(Timestamp, MINUTE)")
tOHLC = btcBin.aggBy(agg_list, "TimestampBin").\
join(btcBin,"CloseTime = Timestamp","Close = Price").\
join(btcBin,"OpenTime = Timestamp","Open = Price")

plotOHLC = ohlcPlot("BTC", tOHLC, "TimestampBin", "Open", "High", "Low", "Close")\
.chartTitle("BTC OHLC - Aug 22 2021")\
.show()

Shared Axes

Just like XY series plots, the Open, High, Low and Close plot can also be used to present multiple series on the same chart, including the use of multiple X or Y axes. An example of this follows:

btcBin = cryptoTrades.where("Instrument=`BTC/USD`").update("TimestampBin = lowerBin(Timestamp, MINUTE)")
ethBin = cryptoTrades.where("Instrument=`ETH/USD`").update("TimestampBin = lowerBin(Timestamp, MINUTE)")

agg_list = [
AggLast("CloseTime = Timestamp"),\
AggFirst("OpenTime = Timestamp"),\
AggMax("High = Price"),\
AggMin("Low = Price"),
]

btcOHLC = btcBin.aggBy(agg_list, "TimestampBin").\
join(btcBin,"CloseTime = Timestamp","Close = Price").\
join(btcBin,"OpenTime = Timestamp","Open = Price")

ethOHLC = ethBin.aggBy(agg_list, "TimestampBin").\
join(ethBin,"CloseTime = Timestamp","Close = Price").\
join(ethBin,"OpenTime = Timestamp","Open = Price")

plotOHLC = ohlcPlot("BTC", btcOHLC, "TimestampBin", "Open", "High", "Low", "Close")\
.chartTitle("BTC and ETC OHLC - Aug 22 2021")\
.twinX()\
.ohlcPlot("ETH", ethOHLC, "TimestampBin", "Open", "High", "Low", "Close")\
.show()