Interface: TradingTerminalWidgetOptions
Charting Library.TradingTerminalWidgetOptions
Hierarchy
-
Omit
<ChartingLibraryWidgetOptions
,"enabled_features"
|"disabled_features"
|"favorites"
>↳
TradingTerminalWidgetOptions
Properties
additional_symbol_info_fields
• Optional
additional_symbol_info_fields: AdditionalSymbolInfoField
[]
An optional field containing an array of custom symbol info fields to be shown in the Symbol Info dialog.
Refer to Symbology for more information about symbol info.
additional_symbol_info_fields: [
{ title: 'Ticker', propertyName: 'ticker' }
]
Inherited from
Omit.additional_symbol_info_fields
auto_save_delay
• Optional
auto_save_delay: number
A threshold delay in seconds that is used to reduce the number of onAutoSaveNeeded
calls.
auto_save_delay: 5,
Inherited from
Omit.auto_save_delay
autosize
• Optional
autosize: boolean
Boolean value showing whether the chart should use all the available space in the container and resize when the container itself is resized.
Default
false
autosize: true,
Inherited from
Omit.autosize
brokerConfig
• Optional
brokerConfig: SingleBrokerMetaInfo
Defines the configuration flags for the Trading Platform.
broker_config
• Optional
broker_config: SingleBrokerMetaInfo
Defines the configuration flags for the Trading Platform.
charts_storage_api_version
• Optional
charts_storage_api_version: AvailableSaveloadVersions
A version of your backend. Supported values are: "1.0"
| "1.1"
. Study Templates are supported starting from version "1.1"
.
charts_storage_api_version: "1.1",
Inherited from
Omit.charts_storage_api_version
charts_storage_url
• Optional
charts_storage_url: string
Set the storage URL endpoint for use with the high-level saving/loading chart API. Refer to Save and load REST API for more information.
charts_storage_url: 'http://storage.yourserver.com',
Inherited from
Omit.charts_storage_url
client_id
• Optional
client_id: string
Set the client ID for the high-level saving / loading charts API. Refer to Saving and Loading Charts for more information.
client_id: 'yourserver.com',
Inherited from
Omit.client_id
compare_symbols
• Optional
compare_symbols: CompareSymbol
[]
an array of custom compare symbols for the Compare window.
Example:
compare_symbols: [
{ symbol: 'DAL', title: 'Delta Air Lines' },
{ symbol: 'VZ', title: 'Verizon' },
...
];
Inherited from
Omit.compare_symbols
container
• container: string
| HTMLElement
The container
can either be a reference to an attribute of a DOM element inside which the iframe with the chart will be placed or the HTMLElement
itself.
container: "tv_chart_container",
or
container: document.getElementById("tv_chart_container"),
Inherited from
Omit.container
context_menu
• Optional
context_menu: ContextMenuOptions
Use this property to override the context menu. You can also change the menu on the fly using the IChartingLibraryWidget.onContextMenu method.
Inherited from
Omit.context_menu
custom_chart_description_function
• Optional
custom_chart_description_function: ChartDescriptorFunction
Use this property to set your own chart description function. context
will be passed to the function.
This description is read aloud by screen readers when a chart within the layout is selected via the Tab
key.
The function should return either a string with a description or null
to fallback to the default description.
custom_chart_description_function: (context) => {
return Promise.resolve(`Chart ${context.chartIndex + 1} of ${context.chartCount}. ${context.chartTypeName} chart of ${context.symbol}.`);
}
Inherited from
Omit.custom_chart_description_function
custom_css_url
• Optional
custom_css_url: string
Adds your custom CSS to the chart. url
should be an absolute or relative path to the static
folder.
custom_css_url: 'css/style.css',
Inherited from
Omit.custom_css_url
custom_font_family
• Optional
custom_font_family: string
Changes the font family used on the chart including the time scale, price scale, and chart's pane. If you want to customize fonts outside the chart, for example, within Watchlist or another widget, you should use the ChartingLibraryWidgetOptions.custom_css_url property to provide custom CSS styles.
Specify custom_font_family
in Widget Constructor as follows:
custom_font_family: "'Inconsolata', monospace",
The custom_font_family
value should have the same format as the font-family
property in CSS.
To use a font that is not available by default on your system, you should first add this font to your custom CSS.
For example, the code sample below imports a Google font into your custom CSS:
@import url('https://fonts.googleapis.com/css2?family=Inconsolata:wght@500&display=swap');
Inherited from
Omit.custom_font_family
custom_formatters
• Optional
custom_formatters: CustomFormatters
Custom formatters for adjusting the display format of price, date, and time values.
Example:
custom_formatters: {
timeFormatter: {
format: (date) => {
const _format_str = '%h:%m';
return _format_str
.replace('%h', date.getUTCHours(), 2)
.replace('%m', date.getUTCMinutes(), 2)
.replace('%s', date.getUTCSeconds(), 2);
}
},
dateFormatter: {
format: (date) => {
return date.getUTCFullYear() + '/' + (date.getUTCMonth() + 1) + '/' + date.getUTCDate();
}
},
tickMarkFormatter: (date, tickMarkType) => {
switch (tickMarkType) {
case 'Year':
return 'Y' + date.getUTCFullYear();
case 'Month':
return 'M' + (date.getUTCMonth() + 1);
case 'DayOfMonth':
return 'D' + date.getUTCDate();
case 'Time':
return 'T' + date.getUTCHours() + ':' + date.getUTCMinutes();
case 'TimeWithSeconds':
return 'S' + date.getUTCHours() + ':' + date.getUTCMinutes() + ':' + date.getUTCSeconds();
}
throw new Error('unhandled tick mark type ' + tickMarkType);
},
priceFormatterFactory: (symbolInfo, minTick) => {
if (symbolInfo?.fractional || minTick !== 'default' && minTick.split(',')[2] === 'true') {
return {
format: (price, signPositive) => {
// return the appropriate format
},
};
}
return null; // this is to use default formatter;
},
studyFormatterFactory: (format, symbolInfo) => {
if (format.type === 'price') {
const numberFormat = new Intl.NumberFormat('en-US', { notation: 'scientific' });
return {
format: (value) => numberFormat.format(value)
};
}
if (format.type === 'volume') {
return {
format: (value) => (value / 1e9).toPrecision(format?.precision || 2) + 'B'
};
}
if (format.type === 'percent') {
return {
format: (value) => `${value.toPrecision(format?.precision || 4)} percent`
};
}
return null; // this is to use default formatter;
},
}
Remark: tickMarkFormatter
must display the UTC date, and not the date corresponding to your local timezone.
Inherited from
Omit.custom_formatters
custom_indicators_getter
• Optional
custom_indicators_getter: (PineJS
: PineJS
) => Promise
<readonly CustomIndicator
[]>
Function that returns a Promise object with an array of your custom indicators.
PineJS
variable will be passed as the first argument of this function and can be used inside your indicators to access internal helper functions.
Refer to Custom indicators for more information.
custom_indicators_getter: function(PineJS) {
return Promise.resolve([
// *** your indicator object, created from the template ***
]);
},
Type declaration
▸ (PineJS
): Promise
<readonly CustomIndicator
[]>
Parameters
Name | Type |
---|---|
PineJS | PineJS |
Returns
Promise
<readonly CustomIndicator
[]>
Inherited from
Omit.custom_indicators_getter
custom_timezones
• Optional
custom_timezones: CustomAliasedTimezone
[]
List of custom time zones.
Refer to Timezones for more information.
Inherited from
Omit.custom_timezones
custom_translate_function
• Optional
custom_translate_function: CustomTranslateFunction
Use this property to set your own translation function. key
and options
will be passed to the function.
You can use this function to provide custom translations for some strings.
The function should return either a string with a new translation or null
to fallback to the default translation.
For example, if you want to rename "Trend Line" shape to "Line Shape", then you can do something like this:
custom_translate_function: (key, options, isTranslated) => {
if (key === 'Trend Line') {
// patch the title of trend line
return 'Line Shape';
}
return null;
}
Inherited from
Omit.custom_translate_function
datafeed
• datafeed: IBasicDataFeed
| IDatafeedChartApi
& IExternalDatafeed
& IDatafeedQuotesApi
JavaScript object that implements the datafeed interface (IBasicDataFeed) to supply the chart with data. See Connecting Data for more information on the JS API.
datafeed: new Datafeeds.UDFCompatibleDatafeed("https://demo_feed.tradingview.com")
Inherited from
Omit.datafeed
debug
• Optional
debug: boolean
Setting this property to true
will make the chart write detailed API logs into the browser console.
Alternatively, you can use the charting_library_debug_mode
featureset to enable it, or use the setDebugMode
widget method (IChartingLibraryWidget.setDebugMode) .
debug: true,
Inherited from
Omit.debug
disabled_features
• Optional
disabled_features: TradingTerminalFeatureset
[]
The array containing names of features that should be disabled by default. Feature
means part of the functionality of the chart (part of the UI/UX). Supported features are listed in Featuresets.
Example:
disabled_features: ["header_widget", "left_toolbar"],
drawings_access
• Optional
drawings_access: AccessList
You can hide some drawings from the toolbar or add custom restrictions for applying them to the chart.
This property has the same structure as the studies_access
argument. Use the same names as you see in the UI.
Remark: There is a special case for font-based drawings. Use the "Font Icons" name for them. Those drawings cannot be enabled or disabled separately - the entire group will have to be either enabled or disabled.
Example
drawings_access: {
type: 'black',
tools: [
{
name: 'Trend Line',
grayed: true
},
]
},
Inherited from
Omit.drawings_access
enabled_features
• Optional
enabled_features: TradingTerminalFeatureset
[]
The array containing names of features that should be enabled by default. Feature
means part of the functionality of the chart (part of the UI/UX). Supported features are listed in Featuresets.
Example:
enabled_features: ["move_logo_to_main_pane"],
favorites
• Optional
favorites: Favorites
<TradingTerminalChartTypeFavorites
>
See ChartingLibraryWidgetOptions.favorites
fullscreen
• Optional
fullscreen: boolean
Boolean value showing whether the chart should use all the available space in the window.
Default
false
fullscreen: true,
Inherited from
Omit.fullscreen
header_widget_buttons_mode
• Optional
header_widget_buttons_mode: HeaderWidgetButtonsMode
An additional optional field to change the look and feel of buttons on the top toolbar.
By default (if option is omitted) header will be in adaptive mode (fullsize if the window width allows and icons on smaller windows).
Example:
header_widget_buttons_mode: 'fullsize',
Inherited from
Omit.header_widget_buttons_mode
height
• Optional
height: number
The desired height of a widget. Please make sure that there is enough space for the widget to be displayed correctly.
height: 600,
Remark: If you want the chart to use all the available space use the fullscreen
parameter instead of setting it to '100%'.
Inherited from
Omit.height
interval
• interval: ResolutionString
The default interval for the chart.
Example:
interval: '1D',
Inherited from
Omit.interval
library_path
• Optional
library_path: string
A path to a static
folder.
library_path: "charting_library/",
- If you would like to host the library on a separate origin to the page containing the chart then please view the following guide: Hosting the library on a separate origin.
Inherited from
Omit.library_path
load_last_chart
• Optional
load_last_chart: boolean
Set this parameter to true
if you want the library to load the last saved chart for a user. You should implement save/load first to make it work.
load_last_chart: true,
Inherited from
Omit.load_last_chart
loading_screen
• Optional
loading_screen: LoadingScreenOptions
Customization of the loading spinner. Value is an object with the following possible keys:
backgroundColor
foregroundColor
Example:
loading_screen: { backgroundColor: "#000000" }
Inherited from
Omit.loading_screen
locale
• locale: LanguageCode
Locale to be used by the library. See Localization section for details.
locale: 'en',
Inherited from
Omit.locale
news_provider
• Optional
news_provider: GetNewsFunction
Use this property to set your own news getter function. Both the symbol
and callback
will be passed to the function.
The callback function should be called with an object. The object should have two properties: title
which is a optional string, and newsItems
which is an array of news objects that have the following structure:
title
(required) - the title of news item.published
(required) - the time of news item in ms (UTC).source
(optional) - source of the news item title.shortDescription
(optional) - Short description of a news item that will be displayed under the title.link
(optional) - URL to the news story.fullDescription
(optional) - full description (body) of a news item.
NOTE: Only title
and published
are the main properties used to compare what has already been published and what's new.
NOTE 2: When a user clicks on a news item a new tab with the link
URL will be opened. If link
is not specified then a pop-up dialog with fullDescription
will be shown.
NOTE 3: If both news_provider
and rss_news_feed
are available then the rss_news_feed
will be ignored.
See News API examples for usage examples.
numeric_formatting
• Optional
numeric_formatting: NumericFormattingParams
The object containing formatting options for numbers. The only possible option is decimal_sign
currently.
numeric_formatting: { decimal_sign: "," },
Inherited from
Omit.numeric_formatting
overrides
• Optional
overrides: Partial
<WidgetOverrides
>
Override values for the default widget properties
You can override most of the properties (which also may be edited by user through UI)
using overrides
parameter of Widget Constructor. overrides
is supposed to be an object.
The keys of this object are the names of overridden properties.
The values of these keys are the new values of the properties.
Example:
overrides: {
"mainSeriesProperties.style": 2
}
This code will change the default series style to "line". All customizable properties are listed in separate article.
Inherited from
Omit.overrides
restConfig
• Optional
restConfig: RestBrokerConnectionInfo
Connection configuration settings for Rest Broker API
rss_news_feed
• Optional
rss_news_feed: RssNewsFeedParams
Use this property to change the RSS feed for news. You can set a different RSS for each symbol type or use a single RSS for all symbols. The object should have the default
property, other properties are optional. The names of the properties match the symbol types. Each property is an object (or an array of objects) with the following properties:
url
- is a URL to be requested. It can contain tags in curly brackets that will be replaced by the terminal:{SYMBOL}
,{TYPE}
,{EXCHANGE}
.name
- is a name of the feed to be displayed underneath the news.
Example
rss_news_feed: {
default: [ {
url: "https://articlefeeds.nasdaq.com/nasdaq/symbols?symbol={SYMBOL}",
name: "NASDAQ"
}, {
url: "http://feeds.finance.yahoo.com/rss/2.0/headline?s={SYMBOL}®ion=US&lang=en-US",
name: "Yahoo Finance"
} ]
},
Example
rss_news_feed: {
"default": {
url: "https://articlefeeds.nasdaq.com/nasdaq/symbols?symbol={SYMBOL}",
name: "NASDAQ"
}
}
Example
rss_news_feed: {
"default": {
url: "https://articlefeeds.nasdaq.com/nasdaq/symbols?symbol={SYMBOL}",
name: "NASDAQ"
},
"stock": {
url: "http://feeds.finance.yahoo.com/rss/2.0/headline?s={SYMBOL}®ion=US&lang=en-US",
name: "Yahoo Finance"
}
}
rss_news_title
• Optional
rss_news_title: string
Title for the News Widget
save_load_adapter
• Optional
save_load_adapter: IExternalSaveLoadAdapter
An object containing the save/load functions. It is used to implement a custom save/load algorithm. Refer to API handlers for more information.
Inherited from
Omit.save_load_adapter
saved_data
• Optional
saved_data: object
JS object containing saved chart content.
Use this parameter when creating the widget if you have a saved chart already.
If you want to load the chart content when the chart is initialized then use load()
method (IChartingLibraryWidget.load) of the widget.
Inherited from
Omit.saved_data
saved_data_meta_info
• Optional
saved_data_meta_info: SavedStateMetaInfo
JS object containing saved chart content meta info.
Inherited from
Omit.saved_data_meta_info
settings_adapter
• Optional
settings_adapter: ISettingsAdapter
An object that contains set/remove functions. Use it to save user settings to your preferred storage, including the server-side one.
Example:
settings_adapter: {
initialSettings: { ... },
setValue: function(key, value) { ... },
removeValue: function(key) { ... },
}
Inherited from
Omit.settings_adapter
settings_overrides
• Optional
settings_overrides: Overrides
The object that contains new values for values saved to the settings. These overrides will replace any matching values from the settings, regardless of where the settings are loaded from (i.e. local storage or a custom settings adapter). The object is similar to the overrides object.
overrides will not affect values that have been saved to settings so this option can be used instead.
settings_overrides: {
"linetooltrendline.linecolor": "blue"
}
Inherited from
Omit.settings_overrides
snapshot_url
• Optional
snapshot_url: string
This URL is used to send a POST request with binary chart snapshots when a user presses the snapshot button.
This POST request contains multipart/form-data
with the field preparedImage
that represents binary data of the snapshot image in image/png
format.
This endpoint should return the full URL of the saved image in the response.
snapshot_url: "https://myserver.com/snapshot",
Inherited from
Omit.snapshot_url
studies_access
• Optional
studies_access: AccessList
You can hide some studies from the toolbar or add custom restrictions for applying them to the chart.
Example
studies_access: {
type: "black" | "white",
tools: [
{
name: "<study name>",
grayed: true
},
< ... >
]
}
Inherited from
Omit.studies_access
studies_overrides
• Optional
studies_overrides: Partial
<StudyOverrides
>
Use this option to customize the style or inputs of the indicators.
You can also customize the styles and inputs of the Compare
series using this argument.
Refer to Indicator Overrides for more information.
Overrides for built-in indicators are listed in StudyOverrides.
studies_overrides: {
"volume.volume.color.0": "#00FFFF",
},
Inherited from
Omit.studies_overrides
study_count_limit
• Optional
study_count_limit: number
Maximum amount of studies allowed at one time within the layout. Minimum value is 2.
study_count_limit: 5,
Inherited from
Omit.study_count_limit
symbol
• Optional
symbol: string
The default symbol for the chart.
Example:
symbol: 'AAPL',
Inherited from
Omit.symbol
symbol_search_complete
• Optional
symbol_search_complete: SymbolSearchCompleteOverrideFunction
Use this property to set a function to override the symbol input from the Symbol Search.
For example, you may want to get additional input from the user before deciding which symbol should be resolved.
The function should take two parameters: a string
of input from the Symbol Search and a optional search result item. It should return a Promise
that resolves with a symbol ticker and a human-friendly symbol name.
NOTE: This override is not called when adding a symbol to the watchlist.
{
// `SearchSymbolResultItem` is the same interface as for items returned to the Datafeed's searchSymbols result callback.
symbol_search_complete: (symbol: string, searchResultItem?: SearchSymbolResultItem) => {
return new Promise((resolve) => {
let symbol = getNewSymbol(symbol, searchResultItem);
let name = getHumanFriendlyName(symbol, searchResultItem)
resolve({ symbol: symbol, name: name });
});
}
}
Inherited from
Omit.symbol_search_complete
symbol_search_request_delay
• Optional
symbol_search_request_delay: number
A threshold delay in milliseconds that is used to reduce the number of search requests when the user enters the symbol name in the Symbol Search.
symbol_search_request_delay: 1000,
Inherited from
Omit.symbol_search_request_delay
theme
• Optional
theme: ThemeName
Set predefined custom theme color for the chart. Supported values are: "light"
| "dark"
.
theme: "light",
Inherited from
Omit.theme
time_frames
• Optional
time_frames: TimeFrameItem
[]
List of visible time frames that can be selected at the bottom of the chart. See Time frame toolbar for more information. Time frame is an object containing the following properties:
Example:
time_frames: [
{ text: "50y", resolution: "6M", description: "50 Years" },
{ text: "3y", resolution: "1W", description: "3 Years", title: "3yr" },
{ text: "8m", resolution: "1D", description: "8 Month" },
{ text: "3d", resolution: "5", description: "3 Days" },
{ text: "1000y", resolution: "1W", description: "All", title: "All" },
]
Inherited from
Omit.time_frames
time_scale
• Optional
time_scale: TimeScaleOptions
An additional optional field to add more bars on screen.
Example:
time_scale: {
min_bar_spacing: 10,
}
Inherited from
Omit.time_scale
timeframe
• Optional
timeframe: TimeframeOption
Sets the default time frame of the chart.
The time frame can be relative to the current date, or a range.
A relative time frame is a number with a letter D for days and M for months:
timeframe: '3M',
A range is an object with to and from properties. The to and from properties should be UNIX timestamps:
timeframe: { from: 1640995200, to: 1643673600 } // from 2022-01-01 to 2022-02-01
Note: When using a range the chart will still request data up to the current date. This is to enable scrolling forward in time once the chart has loaded.
Inherited from
Omit.timeframe
timezone
• Optional
timezone: "exchange"
| Timezone
Default time zone of the chart. The time on the timescale is displayed according to this time zone.
See the list of supported time zones for available values. Set it to exchange
to use the exchange time zone. Use the ChartingLibraryWidgetOptions.overrides section if you wish to override the default value.
timezone: "America/New_York",
Inherited from
Omit.timezone
toolbar_bg
• Optional
toolbar_bg: string
Background color of the toolbars.
toolbar_bg: '#f4f7f9',
Inherited from
Omit.toolbar_bg
trading_customization
• Optional
trading_customization: TradingCustomization
Override customizations for trading
user_id
• Optional
user_id: string
Set the user ID for the high-level saving / loading charts API. Refer to Saving and Loading Charts for more information.
user_id: 'public_user_id',
Inherited from
Omit.user_id
widgetbar
• Optional
widgetbar: WidgetBarParams
Settings for the widget panel on the right side of the chart.
Watchlist, news, details and data window widgets on the right side of the chart can be enabled using the widgetbar
field in Widget Constructor
width
• Optional
width: number
The desired width of a widget. Please make sure that there is enough space for the widget to be displayed correctly.
width: 300,
Remark: If you want the chart to use all the available space use the fullscreen
parameter instead of setting it to '100%'.
Inherited from
Omit.width
Methods
broker_factory
▸ broker_factory(host
): IBrokerTerminal
| IBrokerWithoutRealtime
Use this field to pass the function that returns a new object which implements Broker API. This is a function that accepts the Trading Host (IBrokerConnectionAdapterHost).
Parameters
Name | Type | Description |
---|---|---|
host | IBrokerConnectionAdapterHost | Trading Host |
Returns
IBrokerTerminal
| IBrokerWithoutRealtime
Example
broker_factory: function(host) { ... }