Lipi Reference Lipi

Functions

barcolor()

Recolours the chart's own price bars. It draws no value of its own. To colour only some bars, vary the colour rather than the call: the colour argument is series-form, while the call has to stay at the top level. Note that every argument here is optional, `color` included.

Syntax

                barcolor(series color color, const string title, input int offset) → void
              

Arguments

color series color The colour applied to the bars. Series-form, so it may differ on every bar. Optional.
title const string The name of the colouring. Const-form.
offset input int Shifts the colouring along the chart. Input-form, so it cannot change from bar to bar.

Return Type

void

Example


          indicator("Custom Bar Color", overlay=true)
// Define conditions for different colors
bullish = close > open
bearish = close < open
neutral = close == open
// Assign colors based on conditions
barColor = bullish ? color.green : bearish ? color.red : color.gray
// Apply bar color
barcolor(barColor)