Adds an array of data points to the end of the existing data, or to an empty chart. Allows scrolling data for real-time applications.
Given DateTime values should be newer than the current newest DateTime value on the chart.
Volume and Open Interest values are added only if the values has been assigned to all the new data points.
Assigning data point array:
const dataPoints = [
{ open: 30, high: 40, low: 20, close: 35, dateTime: new Date(2023, 10, 2), volume: 350 },
{ open: 35, high: 45, low: 25, close: 40, dateTime: new Date(2023, 10, 3), volume: 400 }
]
tradingChart.addDataPoint(dataPoints)
Scrolling real-time example showing maximum of 200 data points:
tradingChart.addDataPoint(dataPoints, tradingChart.getPointCount() >= 200)
Array of data point to add. Includes open, high, low, close and dateTime fields as well as optional volume and openInterest values.
Set true to scroll data. Scrolling drops the oldest data points out of visible range, i.e. if five points are added, five oldest points are dropped out of range.
Adds a single data point to the end of the existing data, or to an empty chart. Allows scrolling data for real-time applications.
Assigning data point using current time:
tradingChart.addDataPoint({ open: 30, high: 40, low: 20, close: 35, dateTime: new Date(), volume: 350 })
Scrolling real-time example showing maximum of 200 data points:
tradingChart.addDataPoint({ open: 30, high: 40, low: 20, close: 35, dateTime: new Date(), volume: 350 }, tradingChart.getPointCount() >= 200)
New data point to add. Includes open, high, low, close and dateTime fields as well as optional volume and openInterest values.
Set true to scroll data. Scrolling drops the oldest data point out of visible range.
Adds a heatmap visualization to the chart.
Heatmap start X-position in axis values.
Heatmap start Y-position in axis values.
Heatmap end X-position in axis values.
Heatmap end Y-position in axis values.
Matrix of data values.
The heatmap object.
Adds a secondary symbol with given dataset to the main chart, allowing comparing two symbols.
An array of OHLC-values. Uses the same date time values as the main dataset.
Secondary Symbol, the name of the dataset.
Added symbol as an object.
Adds Symbol search results to the chart, listing them below the search bar.
Array of Symbol search results. Each row can contain Symbol, Name, Region, and Currency fields. Of these, Symbol is mandatory, others are optional. Example array: [ ['GOOG', 'Alphabet Inc - Class C', 'United States', 'USD'], ['GOOGL', 'Alphabet Inc - Class A', 'United States', 'USD'] ]
Converts the given DateTime value to respective index. If the DateTime is between two data points, returns the index of the closest point. Returns null if the DateTime is outside the current data range.
DateTime to convert.
Index, or null if conversion is not possible.
Access all drawing tools.
Object to access all drawing tools.
Enables a limit to data points allowed on the chart. If this limit is exceeded, old points will be automatically dropped. This is useful in real-time applications, where old points can be dropped when out-scrolled, thus freeing memory and improving performance. Use setDataPointLimit() method to set the maximum number of data points.
Set true to enable data point limit.
When enabled, X-axis cannot be zoomed or panned outside the minimum and maximum values of the data set. Disabling this allows free zooming and panning. Note that other zoom/pan related settings may still restrict the zoomable/pannable range.
Set true to enable X-axis restrictions.
When enabled, Y-axis cannot be zoomed or panned outside the minimum and maximum values of the data set. Disabling this allows free zooming and panning. Note that other zoom/pan related settings may still restrict the zoomable/pannable range.
Set true to enable Y-axis restrictions.
Gets the current data set loaded to the chart as separate arrays or as a single XOHLC-type array.
When enabled, returns the data set as a single XOHLC-typed array. Does not contain DateTime values.
If singleArray is enabled, returns the XOHLC-array. If disabled, returns an array of arrays containing the following:
-Date array, the dates are in string format.
-Array of Open values.
-Array of High values.
-Array of Low values.
-Array of Close values.
Gets the internal LightningChart component. Note that TradingChart is built using this chart instance. Modifying it may therefore cause unwanted changes in TradingChart's behaviour, if not break its features altogether.
Gets the current Point-and-Figure chart instance. Useful when changing Point-and-Figure settings in code.
Point-and-Figure chart instance, or null if the current chart type is not Point-and-Figure.
Gets the table component used to display Symbol search results. Each result is a separate table row. Can be used to subscribe to various events when using the search bar with user-defined data provider.
Symbol search table component.
Gets the current selected time range (time range button value). To get the exact time range start and end values, use getTimeRange() method.
Selected time range button value as a number:
0 = All
1 = 10Y
2 = 5Y
3 = 3Y
4 = 1Y
5 = 6M
6 = 3M
7 = 1M
8 = 10D
9 = 5D
10 = 1D
11 = 12H
12 = 3H
13 = 1H
14 = 30m
15 = 10m
16 = 1m
Gets the zoom band chart instance. Returns undefined if the main chart doesn't have a zoom band chart. Note that modifying the zoom band chart may break some of its functionalities since TradingChart is already using this instance.
Access all indicators.
Object to access all indicators.
Calculate the chart layout again.
This is used to inform charts that their position may have changed as a result of an Event that the charts are not aware of. For example, if the chart is positioned within a scrollable DIV.
// Example syntax, trigger chart layout when it is scrolled.
div.onscroll = () => chart.layout()
Reads the given csv-string and converts it into a data array, which is then added to the chart. Replaces existing data.
csv-string to read.
Name of the dataset, shown as the chart title. Optional.
Character used to separate entries, comma by default.
Contains various functions to configure the settings and color menus.
tradingChart.menuOptions().showTitleInput(true)
Functions to configure the menus.
When enabled, right-clicking drawing tool points opens their settings menu.
Set true to enable menus.
Shows or hides the Allow hiding toolbar checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Angle input in the color menu.
Show/hide the input.
Shows or hides the Axis color input in the color menu.
Show/hide the input.
Shows or hides the Price axis on right checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Background color input in the color menu.
Show/hide the input.
Shows or hides the Border color input in the color menu.
Show/hide the input.
Shows or hides the Bottom padding input in the settings menu.
Shows or hides the Candle auto width checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Chart title input in the settings menu.
Show/hide the input.
Shows or hides the Currency input in the settings menu.
Show/hide the input.
Shows or hides the Cursor tracking dropdown in the settings menu.
Show/hide the dropdown.
Shows or hides the Data limit input in the settings menu.
Show/hide the input.
Shows or hides the Data packing checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Enable data limit checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Fill style dropdown in the color menu.
Show/hide the dropdown.
Shows or hides the Gradient color input in the color menu.
Show/hide the input.
Shows or hides the Gradient speed input in the color menu.
Show/hide the input.
Shows or hides the Show horizontal line checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the latest value label type dropdown in the settings menu.
Show/hide the dropdown.
Shows or hides the Left padding input in the settings menu.
Shows or hides the Line color input in the color menu.
Show/hide the input.
Shows or hides the Mountain gradient checkbox in the color menu.
Show/hide the checkbox.
Shows or hides the Negative body input in the color menu.
Show/hide the input.
Shows or hides the Negative wick input in the color menu.
Show/hide the input.
Shows or hides the Panning dropdown in the settings menu.
Show/hide the dropdown.
Shows or hides the Percent scale checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Positive body input in the color menu.
Show/hide the input.
Shows or hides the Positive wick input in the color menu.
Show/hide the input.
Shows or hides the Radial center X input in the color menu.
Show/hide the input.
Shows or hides the Radial center Y input in the color menu.
Show/hide the input.
Shows or hides the Rectangle zooming dropdown in the settings menu.
Show/hide the dropdown.
Shows or hides the Restrict X-axis checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Restrict Y-axis checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Result table position dropdown in the settings menu.
Show/hide the dropdown.
Shows or hides the Right padding input in the settings menu.
Shows or hides the Zooming sensitivity input in the settings menu.
Shows or hides the Series area color input in the color menu.
Show/hide the input.
Shows or hides the Shadow/Glow effect checkbox in the color menu.
Show/hide the checkbox.
Shows or hides the Show border checkbox in the color menu.
Show/hide the checkbox.
Shows or hides the Show file selection checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Show image checkbox in the color menu.
Show/hide the checkbox.
Shows or hides the Show splitter lines checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Show chart title in the settings menu.
Show/hide the checkbox.
Shows or hides the Show watermark checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Splitter color input in the color menu.
Show/hide the input.
Shows or hides the Theme dropdown in the color menu.
Show/hide the dropdown.
Shows or hides the Top padding input in the settings menu.
Shows or hides the Show value labels checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Show vertical line checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Vertical panning checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Vertical zooming checkbox in the settings menu.
Show/hide the checkbox.
Shows or hides the Watermark text input in the settings menu.
Show/hide the input.
Shows or hides the Wheel zooming dropdown in the settings menu.
Show/hide the dropdown.
Shows or hides the X-axis left button interaction dropdown in the settings menu.
Show/hide the dropdown.
Shows or hides the X-axis right button interaction dropdown in the settings menu.
Show/hide the dropdown.
Shows or hides the Y-axis left button interaction dropdown in the settings menu.
Show/hide the dropdown.
Shows or hides the Y-axis right button interaction dropdown in the settings menu.
Show/hide the dropdown.
Shows or hides the Zoom band chart checkbox in the settings menu.
Show/hide the checkbox.
Event that triggers when the chart is clicked. Unlike other click events, this event triggers also above margins and menus.
Event handler containing 'axisX' and 'axisY' parameters indicating the clicked point of the chart in axis coordinates. 'pixelsX' and 'pixelsY' parameters indicate the clicked point of the chart in screen coordinates (pixels). 'button' indicates the pressed mouse button.
Event that triggers when a new dataset has been added to the chart. Adding or removing data points also triggers the event.
Event handler containing 'pointCount' parameter indicating the total number of data points after data modification.
Event that triggers when pointer (mouse) button is pressed down on the chart area.
Event handler containing 'axisX' and 'axisY' parameters indicating the clicked point of the chart in axis coordinates. 'pixelsX' and 'pixelsY' parameters indicate the clicked point of the chart in screen coordinates (pixels). 'button' indicates the pressed mouse button.
Event that triggers when pointer is moved over the chart area.
Event handler containing 'axisX' and 'axisY' parameters indicating the current pointer position in axis coordinates. 'pixelsX' and 'pixelsY' parameters indicating the current pointer position in screen coordinates (pixels).
Event that triggers when pointer (mouse) button is released on the chart area.
Event handler containing 'axisX' and 'axisY' parameters indicating the release point in axis coordinates. 'pixelsX' and 'pixelsY' parameters indicate the release point in screen coordinates (pixels). 'button' indicates the released mouse button.
Saves current chart layout as a template including:
-Chart settings
-Color settings
-Added technical indicators and their settings
-Added drawing tools and their settings
Template excludes:
-Added trading data
-Added heatmaps
Name of the file.
Sets the alignment of the price axes.
Note that changing axis alignment forces the chart to reload itself, which can cause loss of some information, for example drawing tools. For the same reason, when setAxisAlignment() is used in code, the alignment cannot be changed via chart setting menu.
Axis alignment can also be set when creating the chart object, which can avoid the above issue:
tradingChart({axisOnRight: true})
Set true to place the price axes on the right side of the chart. False places them on the left.
Sets the background color of the whole chart, meaning both margin area and series area. Note that series background area color is also controlled via setSeriesBackgroundColor() -method.
New background color as string, should be in HEX format e.g. #FFFFFF.
Sets the color theme of the chart. This overrides all manually set colors.
Note that changing color theme forces the chart to reload itself, which can cause loss of some information, for example drawing tools. For the same reason, when setColorTheme() is used in code, the theme cannot be changed via color setting menu.
Color theme can also be set when creating the chart object, which can avoid the above issue:
tradingChart({colorTheme: Themes.darkGold})
New color theme.
Sets new trading data to the chart, replacing old data. Data is automatically sorted according to DateTime values.
Array of new data points. Each point contains open, high, low, close and dateTime values, as well as optional volume and openInterest fields.
Sets the amount of empty space in pixels left between the data and the chart edges. The top and bottom padding do not affect indicators in their own segments below the main chart.
The padding between the data and the top edge
The padding between the data and the right edge
The padding between the data and the bottom edge
The padding between the data and the left edge
Sets the maximum number of data points that can be shown on the chart. If the limit is exceeded, old points will be automatically dropped. Use enableDataPointLimit() method enable and disable this limit.
Maximum number of data points in chart.
Sets the type of the label marking the latest price value. Doesn't affect other value labels such as indicators' labels.
Value label type.
Sets which value the cursor tracks, and is shown in the price axis label.
Value to track.
Sets the mouse button used for panning. Note that panning and rectangle zooming cannot be assigned to the same button.
Button for panning.
Set the type of the main price chart.
New price chart type.
Sets the mouse button used for rectangle zooming. Note that rectangle zooming and panning cannot be assigned to the same button.
Button for rectangle zooming.
Sets the visibility and the position of the result table.
The position of the result table.
Sets the color of the background area where the data is drawn.
New background color as string, should be in HEX format e.g. #FFFFFF.
Optional background fill style. Default option is solid, single color fill.
Gradient color used when fillStyle is set to LinearGradient or RadialGradient. The gradient is formed between this and the given newColor parameter.
Angle of the linear gradient in degrees (0-360).
Controls how fast the gradient turns from newColor to gradientColor. Value of 1 signifies even distribution between the two colors. Values smaller than 1 cause faster transition while values larger than 1 cause slower transition.
X-position of radial gradient's center. 0 = left edge, 1 = right edge.
Y-position of radial gradient's center. 0 = bottom of the chart, 1 = top of the chart.
Sets the time range. Data values only within this range will be shown. If given time values are before or after the data range, automatically uses the first or the last data value respectively. If you need to show areas outside the data range, use ZoomToRange() method.
Start time.
End time.
Sets how the chart is zoomed when mouse wheel is used. Wheel zooming is also affected by vertical zooming setting.
Wheel zooming mode.
Sets the action happening when the X-axis is being dragged with the left mouse button.
Axis interaction type.
Sets the action happening when the X-axis is being dragged with the right mouse button.
Axis interaction type.
Sets the action happening when the Y-axis is being dragged with the left mouse button.
Axis interaction type.
Sets the action happening when the Y-axis is being dragged with the right mouse button.
Axis interaction type.
Updates the last (newest) data point of the current set displayed in the chart. Does not update the time stamp of the point, only OHLC-values as well as optional Volume and Open Interest values.
Open value for the last data point.
High value for the last data point.
Low value for the last data point.
Close value for the last data point.
Volume value for the last data point. Is optional.
Open Interest value for the last data point. Is optional.
Zooms horizontally to given time range. Price axis (vertical direction) remains unaffected. If X-axis restrictions are enabled (enableXAxisRestrictions), automatically uses the first or the last data value respectively even if the given time values are before or after the data range.
Start time
End time
Trading chart main class.