关闭整组输入?

Turn The Whole Group of Inputs Off?

我有一个会话脚本,我目前可以一个接一个地关闭会话(伦敦会话、纽约会话、东京会话、悉尼会话),但我希望能够将它们全部关闭1 个复选框。

此外,我知道我可以单击眼球隐藏左上角的指示器,但如果可能的话我想在设置中执行此操作。

pinescript:

//@version=5


indicator('Sessions', overlay=true)

bgColor = input(title='Activate High/Low View', defval=false)

LondonColor = color.green
NYColor = color.red
AsiaColor = color.yellow
SydneyColor = color.navy

///Session Times
res = input.timeframe(title='Resolution', defval='D', options=['D', 'W', 'M'])
london = input.session(title='London Session', defval='0300-1200:1234567')
ny = input.session(title='New York Session', defval='0800-1700:1234567')
tokyo = input.session(title='Tokyo Session', defval='2000-0400:1234567')
sydney = input.session(title='Sydney Session', defval='1700-0200:1234567')

//Bars
is_newbar(sess) =>
    t = time(res, sess)
    na(t[1]) and not na(t) or t[1] < t

is_session(sess) =>
    not na(time(timeframe.period, sess))

//London
London = input(title='London Session', defval=true, group='one checkbox')
londonSession = is_session(london)
bgcolor(londonSession and London and not bgColor ? LondonColor : na, transp=90)

//New York
NY = input(title='New York Session', defval=true, group='one checkbox')
nyNewbar = is_newbar(ny)
nySession = is_session(ny)
bgcolor(nySession and NY and not bgColor ? NYColor : na, transp=90)

//Tokyo
Tokyo = input(title='Tokyo Session', defval=true, group='one checkbox')
tokyoSession = is_session(tokyo)
bgcolor(tokyoSession and Tokyo and not bgColor ? AsiaColor : na, transp=90)

//Sydney
Sydney = input(title='Sydney Session', defval=false, group='one checkbox')
sydneySession = is_session(sydney)
bgcolor(sydneySession and Sydney and not bgColor ? SydneyColor : na, transp=90)

您可以添加另一个 input.bool() 并将其与 bgcolor() 中使用的现有条件结合起来

showSessions = input.bool(true, title = "Display Sessions?")
...
...
londonSession = showSessions and is_session(london)
...
...
nySession = showSessions and is_session(ny)
...
etc