Kalmb
Pine Script Scholar
Pine Script Scholar
Posts: 8
Joined: February 22nd, 2022

background color based on volume

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)

processingclouds
Pine Script Master
Pine Script Master
Posts: 115
Joined: January 30th, 2022

Re: background color based on volume

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)


Kalmb
Pine Script Scholar
Pine Script Scholar
Posts: 8
Joined: February 22nd, 2022

Re: background color based on volume

Wow super genius .Works great my friend.

Thanks a lot

Return to “Pine Script Q&A”