Reputation: 2811
I have a toggle at the top of my indicator where I determine if I'm using a Light or Dark Color Theme:
toggleDarkColors = input.bool(true, title = "Toggle Dark Colors", group=g2)
toggleLightColors = input.bool(false, title = "Toggle Light Colors", group=g2)
Colors:
londonTradingWDColor = color.new(#66d9ef, 99) // Dark
londonTradingWLColor = color.new(#66d9ef, 93) // Light
I use the colors above to display my trading window on my chart:
LondonTW = input(title='London Trading Window', defval=true, group=g6)
londonTradingWindow = toggleTradingWindow and is_session(londonTradingW)
bgcolor(toggleDarkColors and londonTradingWindow and LondonTW ? londonTradingWDColor : na)
bgcolor(toggleLightColors and londonTradingWindow and LondonTW ? londonTradingWLColor : na)
The 2 issues I'm having is when I click on the "Style" menu in the indicator settings:
#01
I have 2 checkboxes with "Background Color" displaying because I have 2 bgcolor()'s above. Is there any way to dislay only 1 instead of 2 depending on which Color theme is toggled? I tried if statements:
LondonTW = input(title='London Trading Window', defval=true, group=g6)
londonTradingWindow = toggleTradingWindow and is_session(londonTradingW)
LOTWDark = bgcolor(londonTradingWindow and LondonTW ? londonTradingWDColor : na)
LOTWLight = bgcolor(londonTradingWindow and LondonTW ? londonTradingWLColor : na)
if toggleDarkColors
LOTWDark
if toggleLightColors
LOTWLight
I got the error: line 551: Void expression cannot be assigned to a variable
Line 551 is LOKZDark = bgcolor(londonOKillZone and LondonOKZ ? londonOpenKZDColor : na)
#02
How do I alter the bgcolor()
above code to give it a title? I checked bgcolor()
on tradingviews pinescript v5 page and I couldn't figure it out.
Any suggestions?
Upvotes: 0
Views: 517
Reputation: 21199
#1
No it is not possible. But why don't you use one input for that? Say you only keep toggleDarkColors
and if it is true
then it is dark color. If it is false
, then it is light color.
#2
bgcolor()
has a title
argument.
bgcolor(color, offset, editable, show_last, title) → void
title (const string) Title of the bgcolor. Optional argument.
Use one input for the color option. If true
, use dark color, if false
use light color. One variable for the color is enough. Then use this variable in bgcolor()
.
toggleDarkColors = input.bool(true, title = "Toggle Dark Colors", group=g2)
londonTradingColor = toggleDarkColors ? color.new(#66d9ef, 99) : color.new(#66d9ef, 93)
bgcolor(londonTradingWindow and LondonTW ? londonTradingColor : na)
Upvotes: 2