Functions
bgcolor()
Fill background of bars with specified color.
Syntax
bgcolor(series color color, const string title, input int offset, const bool force_overlay) → void
Arguments
color series color Color of the filled background. You can use predefined constants such as 'blue' or '#00ff7f', as well as complex expressions like 'close >= open ? color.yellow : color.blue'. This is a required argument. title const string Title of the bgcolor. Optional argument offset input int Shifts the color series to the left or to the right on the given number of bars. Default is 0. force_overlay const bool If true, the plotted results will display on the main chart pane, Optional. The default is false. Return Type
void Example
indicator("Custom Background Color", overlay=true)
bullish = close > open
bearish = close < open
bgColor = bullish ? color.green : bearish ? color.red : na
bgcolor(bgColor)