繁体   English   中英

如何一键启用或禁用以下指标

[英]how to to enable or disable the following indicator in one click

如何使用这个 synax input(title="enable",type=input.bool) 一键启用或禁用指示器

'''// @version=4 study(title="动态支撑和阻力", shorttitle="DSR", overlay=true)

// Get user input
emaMainLength = input(title="Longterm EMA Length", type=input.integer, defval=200, minval=1)
emaDSR1Length = input(title="DSR 1 EMA Length", type=input.integer, defval=50, minval=1)
emaDSR2Length = input(title="DSR 2 EMA Length", type=input.integer, defval=20, minval=1)

// Get EMAs
ema200 = ema(close, emaMainLength)
ema50 = ema(close, emaDSR1Length)
ema20 = ema(close, emaDSR2Length)
bearTrend = ema200 > ema50 and ema50 > ema20  // Bearish trend
bullTrend = ema200 < ema50 and ema50 < ema20 // Bullish trend

// Draw invisible plot lines required for zone color fill
z1 = plot(ema20, color=na, transp=100)
z2 = plot(ema50, color=na, transp=100)

// Fill zone
fill(z1, z2, color=bearTrend ? color.red : na, transp=75)
fill(z1, z2, color=bullTrend ? color.lime : na, transp=75)

// Draw long-term EMA
plot(ema200, color=bearTrend ? color.red : na, linewidth=2, transp=0)
plot(ema200, color=bullTrend ? color.green : na, linewidth=2, transp=0)
'''

在选择 plot 时,您可以使用带na的三元。 如:

display = input(title="enable",type=input.bool, defval=true)
plot(display ? ema200 : na, color=bearTrend ? color.red : na, linewidth=2, transp=0)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM