如何为每日区域添加复选框

How to add check box for Daily zone

下面是我的代码..如何为这个每日区域添加输入复选框。当我启用这个区域时应该是可见的。我尝试添加 last 4 四行来实现,但如果我启用最后 f4 行,它会抛出错误。如何解决这个问题?

Daily = input(title="DailyBand", type=bool, defval=false)

//Average Daily Range Levels - 10 day
study(title="Trade Zones", shorttitle="Trade Zones", overlay=true) 


//dayHigh=security(tickerid, 'D', high[1]) 
DOPEN=security(tickerid, 'D', open) 

//ADR L
ddayrange=(high - low)

dr1 = security(tickerid, 'D', ddayrange[1]) 
dr2 = security(tickerid, 'D', ddayrange[2]) 
dr3 = security(tickerid, 'D', ddayrange[3]) 
dr4 = security(tickerid, 'D', ddayrange[4])
dr5 = security(tickerid, 'D', ddayrange[5])
dr6 = security(tickerid, 'D', ddayrange[6]) 
dr7 = security(tickerid, 'D', ddayrange[7]) 
dr8 = security(tickerid, 'D', ddayrange[8]) 
dr9 = security(tickerid, 'D', ddayrange[9])
dr10 = security(tickerid, 'D', ddayrange[10])

dadr_10 = (dr1+dr2+dr3+dr4+dr5+dr6+dr7+dr8+dr9+dr10) /10
dadr_9 = (dr1+dr2+dr3+dr4+dr5+dr6+dr7+dr8+dr9) /9
dadr_8 = (dr1+dr2+dr3+dr4+dr5+dr6+dr7+dr8) /8
dadr_7 = (dr1+dr2+dr3+dr4+dr5+dr6+dr7) /7
dadr_6 = (dr1+dr2+dr3+dr4+dr5+dr6) /6
dadr_5 = (dr1+dr2+dr3+dr4+dr5) /5
dadr_4 = (dr1+dr2+dr3+dr4) /4
dadr_3 = (dr1+dr2+dr3) /3
dadr_2= (dr1+dr2)/2
dadr_1 = dr1

//plot 
dadrhigh10=plot((DOPEN+(dadr_10/2)) , title="Day ADR 
High10",style=circles,color=red,linewidth=1) 
dadrlow10=plot((DOPEN-(dadr_10/2)), title="Day ADR LOW10",style=circles, 
color=red,linewidth=1)
dadrhigh5=plot((DOPEN+(dadr_5/2)) , title="Day ADR 
High5",style=circles,color=red,linewidth=1) 
dadrlow5=plot((DOPEN-(dadr_5/2)), title="Day ADR LOW5",style=circles, 
color=red,linewidth=1)

fill(dadrlow10,dadrlow5,color=red)
fill(dadrhigh10,dadrhigh5,color=red)

//Show when selected
//plot(Daily ? dadrhigh10 : na , color=red, title="Day Upper Band")
//plot(Daily ? dadrhigh5 : na , color=red, title="Day Upper Band")
//plot(Daily ? dadrlow10 : na , color=red, title="Day Lower Band")
//plot(Daily ? dadrlow5 : na , color=red, title="Day Lower Band")e

dadrhigh10 dadrhigh5 dadrlow10dadrlow5 属于 plot 类型。因此,您正在尝试绘制一个行不通的图以及错误消息告诉您的内容。

改为将您的条件添加到其他地块。

dadrhigh10=plot(Daily ? (DOPEN+(dadr_10/2)) : na, title="Day ADR High10",style=circles,color=red,linewidth=1) 
dadrlow10=plot(Daily ? (DOPEN-(dadr_10/2)) : na, title="Day ADR LOW10",style=circles, color=red,linewidth=1)
dadrhigh5=plot(Daily ? (DOPEN+(dadr_5/2))  : na, title="Day ADR High5",style=circles,color=red,linewidth=1) 
dadrlow5=plot(Daily ? (DOPEN-(dadr_5/2)) : na, title="Day ADR LOW5",style=circles, color=red,linewidth=1)