Skip to main content

Trading overrides

info

Trading overrides are only available in Trading Platform.

This article explains how to use the trading_customization property and the Overrides API to customize trading elements, including order and position lines, profit and loss information, and visibility settings.

Customize order and position lines

You can override the style of order and position lines using the trading_customization property of the Widget Constructor. This property is defined by the TradingCustomization interface, which offers four customization options:

Created with Broker API

The Broker API is a component that enables trading. When the chart is initially loaded, the library requests user's orders and positions from the Broker API implementation through the orders and positions methods.

Order and position lines are displayed on the chart. You can override their style using the brokerOrder and brokerPosition properties of the trading_customization object. See BrokerOrderOverrides and BrokerPositionOverrides for full lists of override properties.

new TradingView.widget({
/* Other Widget Constructor properties */

trading_customization: {
brokerOrder: { /* Override properties for order lines */ },
brokerPosition: { /* Override properties for position lines */ },
},
})

The example below shows how to create order and position lines using the Broker API and customize their colors. Note that "normal" in the property name indicates the line is active and visible in the UI, while "disabled" means the line is inactive, such as when another dialog is open.

Created with trading primitives

caution

Starting from version 29, the methods for creating trading primitives are only available in Trading Platform.

Trading primitives is a low-level mechanism for creating order and position lines using the createOrderLine and createPositionLine methods. You can override the style of these lines using the order and position properties within the trading_customization object. See OrderLineToolOverrides and PositionLineToolOverrides for full lists of override properties.

new TradingView.widget({
/* Other Widget Constructor properties */

trading_customization: {
order: { /* Override properties for order lines */ },
position: { /* Override properties for position lines */ },
}
})

The example below shows how to create order and position lines and customize their quantity text color, line color, style, and width.

Adjust display of trading features

The Overrides API offers properties to adjust the display, alignment, and style of profit and loss information, as well as manage the visibility of positions, orders, and execution details. The properties are listed on the ChartPropertiesOverrides page and their names start with tradingProperties.

For example, you can hide profit and loss values for bracket orders.

widget.applyOverrides({
"tradingProperties.bracketsPL.visibility": false,
});