Elder's Force Index Color Bar
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © salted-fish

//@version=4

study(title="Elder's Force Index Color Bar", shorttitle="EFI color bar", overlay=true)
length_EFI = input(2, minval=1)
Length_EMA = input(6, "Length_EMA")
usevolume = input(true)
efi_short = usevolume ? ema(change(close) * volume, length_EFI) : ema(change(close), length_EFI)
ema = ema(efi_short, Length_EMA)
e_bulls        = (efi_short > 0) and (ema > 0)
e_upsig        = (efi_short < 0) and (ema > 0)
e_bears        = (efi_short < 0) and (ema < 0)
e_downsig      = (efi_short > 0) and (ema < 0)
e_color = e_bulls ? color.green : e_bears ? color.red : e_upsig ? #ffff03: #0011ff
barcolor(e_color)