Page 1 of 1

background color based on volume

Posted: Thu Feb 24, 2022 7:52 am
by Kalmb
Hello,

I want to use background color to chart when volume bigger that the last 3 bars.

please check what's wrong with this formula

thanks

indicator("volume detector", overlay=true)

VolDetector = volume > volume[1] and volume > volume[2] and volume > volume[3]

bgcolor(VolDetector ? color = color.white : na)

Re: background color based on volume

Posted: Thu Feb 24, 2022 4:56 pm
by processingclouds
Hey,

Correct line for the bgcolor would be as :

Code: Select all

bgcolor(color = VolDetector ? color.white : na)

Also another way of doing the above can be as:

Code: Select all

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © processingclouds

//@version=5
indicator("volume detector", overlay=true)
bgcolor(volume > ta.highest(volume[1], 3) ? color.orange : na)


Re: background color based on volume

Posted: Thu Feb 24, 2022 5:27 pm
by Kalmb
Wow super genius .Works great my friend.

Thanks a lot