Breaking Changes - SpartaCommodities/Trading_view_wiki GitHub Wiki
We do our best to make every next version fully compatible with the previous one, but sometimes big changes require you to make minor changes in your code when upgrading to a new version.
Note: you can check the Charting Library version by executing TradingView.version() in a browser console.
Here is the list of breaking changes:
-
Average close price lineis now masked by default in Chart settings and can be shown by usingshow_average_close_price_line_and_labelfeatureset.
UI changes
-
With this version you will notice that the top toolbar has been redesigned with the following changes:
- Button padding & separator size have been reduced
- Compare button has shifted next to Symbol
- Drawing icon is now more prominent
- New fullscreen icon
- Save button style better highlights when there's a change
- Top toolbar now extends to left & right edges
- UI font changes to a default system one
- Undo/redo buttons are now relocated next to the save button
-
Methods getTimezone and setTimezone have been deprecated and will be removed in future versions. Use getTimezoneApi instead.
-
POST request data format sent to snapshot_url has been changed. Since this version this request contains
multipart/form-datawith the fieldpreparedImagethat represents binary data of the snapshot image inimage/pngformat. -
Optional
inputsarguments for createStudy has been changed from using an array of ordered values to an object with named properties. You can still use array-like inputs but it will be removed in further releases. -
The set of inputs for Moving Average study has been changed and the first input now is a symbol. If you used
createStudyto create Moving Average study you will have to modify the list of inputs by simply adding an empty string as the first element:tvWidget.activeChart().createStudy('Moving Average', true, false, ['', 9]);
instead of
tvWidget.activeChart().createStudy('Moving Average', true, false, [9]);
-
Study
Ichimokuhas been modified with someInputs&Styleproperties renamed. -
Both
scrollPositionanddefaultScrollPositionfrom Chart-Methods have been deprecated in favour of rightOffset and defaultRightOffset accordingly. -
The
rest.htmlfile anddatafeeds/restdirectory have been removed. -
When subscribed to
drawing_eventaclickis no longer emitted when a drawing is created. Acreateevent is emitted instead. -
Study
True Strength Indicatorhas been renamed toTrue Strength Indexand modified with its style elements being properly named with 1stPlotbecomingTrue Strength Index& secondPlotbecomingSignal.
Trading Terminal
-
The
watchListmethod now returns a promise that resolves a watchlist API object when the watchlist widget has loaded. -
suggestedQtyhas been removed from the Trading Host. -
dome_widgetfeatureset which controls the DOM widget visibility has be deprecated in favour ofdom_widget.
-
Featureset
show_dialog_on_snapshot_readyhas been removed. takeScreenshot makes a snapshot silently, so you can use the URL from onScreenshotReady callback to show your own dialog instead. -
Field
holidaysfrom SymbolInfo has been renamed tosession_holidays. -
changeThemefrom Widget Methods now returns a Promise. You can apply other style modifications after the promise is fulfilled. -
Symbol type
bitcoinhas been renamed tocrypto. -
The symbol search dialog suggestions list uses the
full_nameinstead of theexchangeandsymbolvalue. This data is provided by your implementation of searchSymbols.
Trading Terminal
-
supportModifyOrderflag has been marked deprecated and will be removed in future versions. UsesupportModifyOrderPrice,supportEditAmountandsupportModifyBracketsinstead. -
emptyformatter has been removed. -
Flag
durationForMarketOrdershas been removed from Broker ConfigurationconfigFlagsobject. To use duration with market orders, add appropriate order type tosupportedOrderTypesarray. -
supportReducePositionflag has been removed from the Broker ConfigurationconfigFlagsobject. -
supportExecutionsflag has been added. If broker supports executions you need to set the flag totrue. -
The default value of
ascfield of the SortingParameters has been changed totrue. -
The
customFormattersfield has been removed from the accountManagerInfo. -
id,modificationProperty,fixedWidth,showOnMobileandshowTooltipOnCellfields have been removed from the Account Manager column description. Thepropertyfield has been made mandatory, so you can use it instead ofid. -
The string
idfield has been made mandatory in each table row. -
The return value of the method
placeOrderin the Broker API has been changed fromPromise<void>to Promise<PlaceOrderResult>. -
contextMenuEventtype incontextMenuActionsinAccountManagerInfointerface has been changed fromMouseEventtoMouseEvent | TouchEvent. -
The shape of the
news_providerproperty in the Widget Constructor options has changed. Theis_news_genericandget_newsproperties have been replaced with a single function.
-
Featureset
caption_buttons_text_if_possiblehas been removed and has been replaced by a new parameterheader_widget_buttons_mode -
Featureset
high_density_barshas been removed and replaced bymin_bar_spacing, a new parameter fortime_scale. -
Study
Moving Average Modifiedhas been removed. UseSmoothed Moving Averageinstead. Note that the default value forlengthinput is different.
Trading Terminal
-
unixTimeAgoformatter has been removed. -
Account Manager format function's property
$container: JQueryhas been replaced withcontainer: HTMLElement. Format function returnsstring | HTMLElementinstead ofstring | JQuery. -
Options
showOrderPanel,showDOMandshowSellBuyButtonshave been removed from thedefaultDropdownMenuActionsoptions list. -
The return value of the method
getOrderDialogOptionshas been made a Promise. -
Trading Host
symbolSnapshotmethod has been removed. -
cancellingBracketCancelsParentOrderandcancellingOnePositionBracketsCancelsOtherflags have been removed. They can be partially replaced with thesupportCancellingBothBracketsOnlyflag.
Note: container_id has been marked deprecated. It's now preferable to switch to/use container instead. Container can now be either still be an id or be an HTMLElement you'd like the widget to be attached to.
-
crossHairMoved has been changed from a callback parameter to
crossHairMoved()with aSubscriptionmodel. It will still return the same objectparams: {time, price}. -
force_session_rebuildfield in the symbol info has been removed -
Count and type of getBars arguments has been changed -
from,toandfirstDataRequestarguments have been combined into theperiodParamsobject. To quickly switch to the new version, you need to replace the following code// ... getBars(symbolInfo, resolution, from, to, onHistoryCallback, onErrorCallback, firstDataRequest) { // your code here } // ...
with the following code:
// ... getBars(symbolInfo, resolution, periodParams, onHistoryCallback, onErrorCallback) { let { from, to, firstDataRequest } = periodParams; // your code here } // ...
-
The
todate in getBars is not inclusive from now. Thefromdate is still inclusive. It means that you don't need to include bars withtime == toin the response. -
Arguments of
ctx.new_symmethod in custom indicators have been changed and now you don't need to pass the third argument (it might break the indicator). To quickly fix this up, find all use cases for thenew_symmethod and make sure that only 2 arguments are passed to it (instead of three or more). For example, if you previously hadctx.new_sym(newSym, PineJS.Std.period(this._context), PineJS.Std.period(this._context)), you need to replace it withctx.new_sym(newSym, PineJS.Std.period(this._context)). -
calculateHistoryDepthmethod from JS-Api has been removed. Consider switching to usage ofcountBackinstead.
Trading Terminal
-
The default value of the
supportPLUpdateflag has been changed totrue. -
Trading Host
defaultDropdownMenuActionsoptions have been changed. OptionsselectAnotherBrokeranddisconnecthave been removed. -
The return value of the method
buttonDropdownActionsin the Trading Host has been changed fromBindPopupMenuActionDescription[]to array of ActionMetaInfo. -
The
orderDialogOptionsobject has been removed from the Broker's Configuration. Please use thegetOrderDialogOptionsmethod to customize the Order dialog. -
The
classNamefield has been removed from the Account Manager column description. Use the alignment field to control the alignment of the cell value.
- Field
futures_regexfrom configurationData has been removed, please use symbols_grouping instead.
Trading Terminal
-
contextMenuEventtype incontextMenuActionsinAccountManagerInfointerface has been changed from JQueryEventObject to MouseEvent. -
accountsListandaccounthave been removed from Account Manager Info. They have been replaced with methodscurrentAccount,setCurrentAccountandaccountsMetainfoin broker's API. -
Method
fullUpdatein the Trading Host has been renamed tocurrentAccountUpdate. -
Method
showClosePositionDialoghas been removed. -
Trading Host method
floatingTradingPanelVisibilityhas been renamed tosellBuyButtonsVisibility. -
Trading Host
defaultDropdownMenuActionsoptions have been changed. OptionshowFloatingToolbarhas been renamed toshowSellBuyButtons. -
Flag
supportOrderPreviewhas been renamed tosupportPlaceOrderPreview. -
Method setPoints now behaves the same way as createMultipointShape for all tools. Previously it could change some other properties like width instead on moving points to their new places.
- The orders response has been split into orders and ordersHistory.
-
Widget Method
setLanguage(locale)has been removed. - The argument of
onIntervalChangedevent have been modified: type oftimeframefield has been changed to TimeFrameValue. - Featureset
same_data_requeryhas been removed, please use resetData() method to refresh the data. -
charting_library/charting_library.min.jsandcharting_library/charting_library.min.d.tsfiles have been renamed tocharting_library/charting_library.jsandcharting_library/charting_library.d.tsaccordingly. - The Chart Method removeEntity now can be undone by the user by default. To disable this, please use
disableUndofield in the new argumentoptions.
Trading Terminal
- Flag
supportBottomWidgethas been removed from Broker ConfigurationconfigFlagsobject. To remove the Account Manager thetrading_account_managerfeatureset should be used.
-
Action
tmzPropertiesfrom executeActionById and getCheckableActionState methods is removed. -
Chart method
createStudyoptions forpriceScalehave been changed.leftandrighthave been renamed tonew-leftandnew-right. -
Series API method
moveToOtherSourceScalehas been renamed tochangePriceScale. New argument options are added:new-left,new-right,no-scale. -
Study API method
changePriceScaleargument options have been changed.leftandrighthave been renamed tonew-leftandnew-right. New argument optionentityIdhas been added, it pins the study to the same price axis as a study with a correspondingentityId. -
Method
applyOverridesof ChartWidget is disabled for "mainSeriesProperties.priceAxisProperties.*". -
Creating a study using
createStudyof ChartWidgetApi can be undone by the user from now. You can disable it usingdisableUndoinoptions.
- Featureset
show_logo_on_all_chartshas been removed. - Featureset
cl_feed_return_all_datahas been removed. - Action
magnetActionfrom executeActionById and getCheckableActionState methods is removed. Use magnetEnabled instead. -
callbackargument of createStudy has been removed. -
createStudy returns Promise instead of
entityId. -
Pane-Api method
getLeftPriceScaleis removed and replaced withgetLeftPriceScalesthat returns an array of scales instead a single element. -
Pane-Api method
getRightPriceScaleis removed and replaced withgetRightPriceScalesthat returns an array of scales instead a single element. - setVisibleRange method now returns a Promise object and don't accept a callback as the last argument.
- Priority of the symbol option has been made higher than the priority of the symbol from the saved_data option. Do not assign a value to the symbol option, if you don't want to override the symbol from saved_data.
- Override
symbolWatermarkPropertiesis not supported anymore. You can use settings_adapter withsymbolWatermarkkey. -
indicators_file_nameconstructor option was removed. Use custom_indicators_getter instead. We made this change to speed up the loading of the library and get rid of possible vulnerabilities that may occur when loading a file. You just need to move the code of your custom indicators from the JS file to the widget constructor, wrapping them in a function and a Promise
Trading Terminal
We've changed the broker's interaction flow. Please read the following carefully to understand what changes should be made in your code to switch to the new version.
Till now the Trading Terminal called broker adapter's methods (e.g. placeOrder, modifyOrder) when user clicked on Buy/Sell/Modify buttons. When calling these methods the Trading Terminal passed a silently argument. When silently was set to true, the broker adapter could send an order without showing the dialog. When it was set to false, the broker adapter had to invoke a method from the host to show the order ticket (or the Edit Position dialog).
Starting from 1.15 the Trading Terminal shows all dialogs by itself and invokes broker adapter's methods to send an order or a position to the broker's server. The reason for this change is that we've added an order panel that can be used to place an order at any time.
If you use your own Order dialog then you still need to make changes in your broker adapter's methods, but additionally you need to use metainfo to pass the dialog constructor to the Trading Terminal.
-
Argument
silentlywas removed fromplaceOrder,modifyOrder,reversePosition,closePosition,closeTrade,cancelOrder,cancelOrdersmethods of the Broker API. -
Arguments
handlerandoptionswere removed fromshowOrderDailogmethod of the Trading Host. -
Argument
handlerwas removed fromshowPositionBracketsDailogmethod of the Trading Host. -
supportCustomPlaceOrderTradableCheckflag is no longer supported. -
We pass the parent order to
modifyOrderif it exists. If child order’s details are required while modifying the order you can get back this behavior by enablingalways_pass_called_order_to_modifyfeatureset.
-
createButton returns
HTMLElementinstead ofJQuery. -
createButton must be used after headerReady()
Promiseis resolved. -
getVisibleRange returns
{from, to}in the UTC timezone (it was a timezone selected on a chart before). - Method
onreadywas removed. You can usewindow.addEventListener('DOMContentLoaded', callback, false)instead. -
saveAsSnapshotparameter was removed from saveChartToServer
TypeScript type definitions
-
StudyInputValueTypetype is renamed toStudyInputValue.
Featureset
- Starting from this version you are no longer able to use the
keep_left_toolbar_visible_on_small_screensfeatureset. This featureset is removed and the left toolbar visibility no longer depends on the screen size.
- Action
takeScreenshotfrom executeActionById method is removed. Use takeScreenshot method instead. - Action
lockDrawingsActionfrom executeActionById and getCheckableActionState methods is removed. Use lockAllDrawingTools instead. - Action
hideAllDrawingsActionfrom executeActionById and getCheckableActionState methods is removed. Use hideAllDrawingTools instead. - Featureset
caption_buttons_text_if_possibleis enabled by default. - Fixed an issue that was causing bars to shift. Time-shifted bars used to appear when daily bars had a negative exchange timezone offset along with a 24x7 session. If you have a workaround for this issue, please remove it before updating to this version.
Charting Library
-
charting_library/charting_library.min.jsis now UMD module.If you only inline this script into HTML then nothing has changed for you. If you import it as a module you should import
widget,versionandonreadyfunctions directly from it. -
searchSymbolsByNameis removed fromJS-API, usesearchSymbolsinstead.
Study overrides:
- Overrides for
Overlayshould be applied only viastudies_overrides(andapplyStudiesOverridesin runtime). In the previous versions you had to useoverridesandapplyOverrides). See Studies-Overrides page. - Starting from this version you are no longer able to override
showStudyArgumentsandshowLastValueusingoptionskeyword.
Trading Terminal
-
hasHistoryflag is removed. UsehistoryColumnsto display History in the Account Manager.
The following items are still supported in the Trading Terminal, but will be deprecated in future versions:
-
subscribePLandunsubscribePL. The broker should callplUpdatemethod of the Host every time the profit is changed. -
supportDOMis removed. DOM widget visibility can be set usingdome_widgetfeatureset.
The Trading Controller is replaced with Broker API.
The following changes should be applied to your Trading Controller implementation to move to new Broker API:
- Method
setHostis removed. Host should be passed to the constructor of Broker API. - Method
buttonDropdownItemsis removed. Broker API should update Broker API usingsetButtonDropdownActions. - Methods
configFlagsanddurationsare removed. Use Widget Constructor fields instead. - All methods that returned
$.Deferredshould be modified to return Promise. - Method
chartContextMenuItemsis renamed tochartContextMenuActions. - Method
isTradablechanged to return a Promise instead of a Boolean value. - All string constants ("working", "buy" etc.) should be replaced with the appropriate number of constants.
- Position
avg_pricerenamed toavgPrice. -
tradingControllerfield in the Widget Constructor is removed. UsebrokerFactoryinstead.
Trading Terminal
The following items are still supported in Trading Terminal, but will be deprecated in future versions:
-
supportDOMErenamed tosupportDOM. - The signature of `showClosePositionDialog has been changed.
-
showEditBracketsDialogwas renamed toshowPositionBracketsDialog.The signature has been changed.
-
Default behavior of Volume indicator was changed.
Previous behavior: Volume indicator is added/removed when an instrument or a resolution is switched depending on volume support by the instrument. You can get back to this behavior by disabling
create_volume_indicator_by_default_oncefeatureset.New behavior: Volume indicator is added when an empty chart is loaded for the first time provided that it is supported by an active instrument.
- We don't compile Pine scripts anymore. You can still use scripts that were compiled earlier.
- The chart can no longer show active orders only. Appropriate methods have been removed.
-
showOrderDialogreceives an object instead of arguments list -
showSampleOrderDialogremoved, use showOrderDialog instead -
showOrderDialogremoved from Broker API, useplaceOrderandmodifyOrderreceivesilentlyargument instead -
reversePosition,closePosition,cancelOrderhave an additional argumentsilently.
- Starting from this version calling
setSymbolwith the same symbol is no longer enough. You should callonResetCacheNeededCallbackfromsubscribeBarsfirst. Then you can usesetSymbolor newresetDatamethod of the chart. - JSAPI protocol version 1 is not supported anymore.
nextTimeandnoDatamust be provided.
-
Added
sourceargument to MACD. You should change MACD creation code to passsourcealso.chartWidget.chart().createStudy('MACD', false, false, [12, 26, "close", 9])
-
Override
transparencyis not supported anymore. We added transparency support to every color. Usergbaform to define a color with transparency. Example:"symbolWatermarkProperties.color" : "rgba(60, 70, 80, 0.05)"
-
Override
paneProperties.gridProperties.*is not supported anymore.Please use
paneProperties.vertGridProperties.*andpaneProperties.horzGridProperties.* -
Override
mainSeriesProperties.candleStyle.wickColoris not supported anymore.Use
mainSeriesProperties.candleStyle.wickUpColorandmainSeriesProperties.candleStyle.wickDownColor