Lipi Reference Lipi

Functions

barcolor()

It Sets color of bars.

Syntax

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

Arguments

color series color Bar color. 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 barcolor. 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.

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)