Barcolor X 2021-9-28
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=4
// Updated to Version 4 2021-7-1
// © geno777
// This barcolor setting adds dimension to whether it's above or below where it was X bars ago by adding a
// longer term argument to filter out sideways price action. For example, the white price bars show when
// the price stayed above where it was five bars ago AND twenty bars ago.
study("Barcolor X 2021-9-28", shorttitle = "BC-X", overlay=true)

// Getting Inputs
len = input(5, minval=1, title="Fast Length")
len2 = input(20, minval=1, title="Slow Length")
src = input(title="Source", type=input.source, defval=close)

// Plot colors
col_grow_above = #ffffff
col_grow_below = #4CAF50
col_fall_above = #0000ff
col_fall_below = #ff0000

// Putting it together.
barcolor(src >= src[len2] ? (src > src[len] ? col_grow_above : col_fall_above) : (src < src[len] ? col_fall_below : col_grow_below))