[英]Using input.source to capture input from a custom indicator (PineScript on Tradingview)
[英]indicator from tradingview default, and one created from pinescript doesnot match
您需要将CCI
计算为security()
scope,而不是ohlc
值:
//@version=4
study(title="Commodity Channel Index", shorttitle="CCI", format=format.price, precision=2, resolution="")
re = input("60", type = input.resolution)
length = input(20, minval=1)
src = input(hlc3, title="Source")
ma = sma(src, length)
cci = security(syminfo.ticker, re, (src - ma) / (0.015 * dev(src, length)))
plot(cci, "CCI", color=#2962FF)
band1 = hline(100, "Upper Band", color=#787B86, linestyle=hline.style_dashed)
band0 = hline(-100, "Lower Band", color=#787B86, linestyle=hline.style_dashed)
fill(band1, band0, color=color.rgb(33, 150, 243, 90), title="Background")
感谢 Starr Luck,这就是我最终的结果:
study("CCi",overlay = false)
length = input(20, minval=1)
src = input(hlc3, title="Source")
ma = sma(src, length)
cci=security(syminfo.tickerid,"60", (src - ma) / (0.015 * dev(src, length)), barmerge.gaps_on, barmerge.lookahead_off )
plot(cci, "CCI", color=#2962FF)
band1 = hline(100, "Upper Band", color=#787B86, linestyle=hline.style_dashed)
band0 = hline(-100, "Lower Band", color=#787B86, linestyle=hline.style_dashed)
fill(band1, band0, color=color.rgb(33, 150, 243, 90), title="Background")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.