Studies Overrides
You can set the default style along with the input values for newly created indicators using the studies_overrides
parameter.
Its value is expected to be an object where key is a path to a property that is going to be changed while value is the new value for it.
Example:
studies_overrides: {
"volume.volume.color.0": "rgba(0, 255, 255, 0.8)",
"volume.volume.color.1": "#0000FF",
"volume.volume ma.color": "rgba(255, 0, 0, 0.7)",
"volume.volume ma.linewidth": 5,
"volume.volume ma.visible": true,
"bollinger bands.median.color": "#33FF88",
"bollinger bands.upper.linewidth": 7
}
In the example above, all created Bollinger Bands will have upper line width set to 7 (unless you create it through an API and specify a different value).
When applying overrides within the createStudy method you can define the following properties:
showPriceLine
: booleanshowLabelsOnPriceScale
: booleanshowLegendValues
: booleantransparency
: numberprecision
: string
Setting the study name
You should use the names of the studies in the Insert Study dialog as they are but using lower case letters.
If you wish to override default EMA's length, try using moving average exponential.length
.
The same logic applies to input names: use names as you see them in the Study Properties dialog (use lower case letters).
Example: stochastic.smooth d
.
Compare
You can customize new series that are added via Compare
.
For instance:
compare.plot
to customize the linecompare.source
to change the price source"compare.plot.color": "#000000",
"compare.source": "high"compare.minTick
to override the 'Min Tick' value (see here for more information).
Overlay
Starting from V 1.12 you may use the following properties to customize Overlay
:
Overlay.style: (bars = 0, candles = 1, line = 2, area = 3, heiken ashi = 8, hollow candles = 9, columns = 13)
Overlay.showPriceLine: boolean
Overlay.allowExtendTimeScale: boolean (whether an overlay should extend time axis, the property is used only when 'secondary_series_extend_time_scale' featureset is enabled)
Overlay.candleStyle.upColor: color
Overlay.candleStyle.downColor: color
Overlay.candleStyle.drawWick: boolean
Overlay.candleStyle.drawBorder: boolean
Overlay.candleStyle.borderColor: color
Overlay.candleStyle.borderUpColor: color
Overlay.candleStyle.borderDownColor: color
Overlay.candleStyle.wickColor: color
Overlay.candleStyle.barColorsOnPrevClose: boolean
Overlay.hollowCandleStyle.upColor: color
Overlay.hollowCandleStyle.downColor: color
Overlay.hollowCandleStyle.drawWick: boolean
Overlay.hollowCandleStyle.drawBorder: boolean
Overlay.hollowCandleStyle.borderColor: color
Overlay.hollowCandleStyle.borderUpColor: color
Overlay.hollowCandleStyle.borderDownColor: color
Overlay.hollowCandleStyle.wickColor: color
Overlay.hollowCandleStyle.barColorsOnPrevClose: boolean
Overlay.barStyle.upColor: color
Overlay.barStyle.downColor: color
Overlay.barStyle.barColorsOnPrevClose: boolean
Overlay.barStyle.dontDrawOpen: boolean
Overlay.columnStyle.upColor: color
Overlay.columnStyle.downColor: color
Overlay.columnStyle.barColorsOnPrevClose: boolean
Overlay.columnStyle.priceSource: open/high/low/close
Overlay.lineStyle.color: color
Overlay.lineStyle.linewidth: integer
Overlay.lineStyle.priceSource: open/high/low/close
Overlay.areaStyle.color1: color
Overlay.areaStyle.color2: color
Overlay.areaStyle.linecolor: color
Overlay.areaStyle.linestyle: (solid = 0; dotted = 1; dashed = 2; large dashed = 3)
Overlay.areaStyle.linewidth: integer
Overlay.areaStyle.priceSource: open/high/low/close
Overlay.minTick: minTick value
(See here for more information about minTick value)
Syntax
Property path is a set of lower case identifiers split with a dot (.
). Path formats are described below.
You can get an error if a plot, band, area, or input name is duplicated in one of the other types. For example, if you have an input and a plot with the same name. The library will show a warning message like this: Study '{Study Name}' has ambiguous identifier '{Property Name}'
if you try to set one of these duplicate cases.
Please refer to the Handling Ambiguous Identifiers section for an explanation on how to handle these cases.
Study input
Format: indicator_name.input_name
- indicator_name: use the name as you see it in the
Indicators
dialog. - input_name: use the name as you see it in the indicator's properties dialog (for example,
show ma
)
Examples: volume.volume ma.visible
, bollinger bands.length
Plot property
Format: indicator_name.plot_name.property_name
- indicator_name: < ... >
- plot_name: as you see it in the indicator's properties dialog (for example,
Volume
orPlot
) - property_name: one of the following:
- linewidth
- visible: boolean
- plottype. Supported plot types are:
line
histogram
cross
area
columns
circles
line_with_breaks
area_with_breaks
step_line
step_line_with_breaks
Examples: volume.volume.linewidth
, bollinger bands.median.linewidth
Plot colors
Format: indicator_name.plot_name.color<.color_index>
- indicator_name: < ... >
- plot_name: < ... >
- color. It's just a keyword.
- color_index (optional): color index (if any). It's just an ordinal number of a color for this plot.
I.e., to replace the color that is green by default for Volume, one should use
color_index = 1
.
Remark 1: color.0
is a synonym of color
. Paths such as volume.volume.color.0
and volume.volume.color
are treated the same.
Remark 2: The customization of area fill color and transparency is not supported currently.
Limitations:
- Only
#RRGGBB
format is supported for colors. Do not use a short format#RGB
. - Transparency varies and the range is [0..100]. 100 means plot is fully opaque.
- Thickness is an integer.
Precision
You can change the default precision of studies using the name.precision
format starting from V 1.6.
Example: "average true range.precision": 8
Handling Ambiguous Identifiers
When the library complains that there is an 'ambiguous identifier', it means that more than one property has that specific property name. This can be possible because there are a few different types (plots, bands, areas, inputs) for the properties and the name only needs to be unique amongst its own type. So there can be cases where the library can not determine which property to change based solely on the name. In these cases you should use the 'colon type' syntax to specifically tell the library which type the property is within.
The type should be specified at the end of the ambiguous name (just before the period), and can be one of the following types:
:plot
:band
:area
:input
Example
The 'Ichimoku Cloud' indicator has both an input and plot named 'Lagging Span', thus to adjust a property on the Lagging Span plot would require a property name like this: Lagging Span:plot.display
when applying the override within the createStudy method.
As an example, here we create an Ichimoku Cloud indicator will all the visual elements disabled (unchecked):
widget.activeChart().createStudy(
'Ichimoku Cloud', // study name
false, // forceOverlay
false, // lock
false, // inputs
{ // overrides
'Conversion Line.display': 0,
'Lagging Span:plot.display': 0, // ambiguous, therefore added :plot
'Lagging Span:input': 20, // ambiguous, therefore added :input
'Leading Span A.display': 0,
'Leading Span B:plot.display': 0, // ambiguous, therefore added :plot
'Base Line.display': 0,
'Plots Background.visible': 0, // filled area therefore used visible instead of display
});