首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PIne脚本:2种不同的背景色

PIne脚本:2种不同的背景色
EN

Stack Overflow用户
提问于 2021-08-20 13:09:19
回答 1查看 59关注 0票数 0

我使用这个代码,我想在80%的行后有一个彩色背景,在20%的行前有另一个背景色

代码语言:javascript
复制
study(title="Stochastic RSI 50", shorttitle="Stoch RSI 50", format=format.price, precision=2, resolution="")
smoothK = input(3, "K", minval=1)
smoothD = input(3, "D", minval=1)
lengthRSI = input(14, "RSI Length", minval=1)
lengthStoch = input(14, "Stochastic Length", minval=1)
src = input(close, title="RSI Source")
rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
plot(k, "K", color=#2962FF)
plot(d, "D", color=#FF6D00)
h0 = hline(80, "Upper Band", color=#787B86)
h1 = hline(20, "Lower Band", color=#787B86)
hm = hline(50, "50 band", color=#787B86)
fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background")

如何让thant在pine手稿中变得可能。

谢谢你的帮忙

EN

回答 1

Stack Overflow用户

发布于 2021-08-20 17:21:40

你的意思是80到100的填充颜色和20到0的填充颜色?如果是,则使用以下代码,

代码语言:javascript
复制
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SafetyHammer

//@version=4
study(title="Stochastic RSI 50", shorttitle="Stoch RSI 50", format=format.price, precision=2, resolution="")
smoothK = input(3, "K", minval=1)
smoothD = input(3, "D", minval=1)
lengthRSI = input(14, "RSI Length", minval=1)
lengthStoch = input(14, "Stochastic Length", minval=1)
src = input(close, title="RSI Source")
rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
plot(k, "K", color=#2962FF)
plot(d, "D", color=#FF6D00)


h0 = hline(0, "Upper Band 0 &", color=#787B86)
h1 = hline(20, "Lower Band 20 %", color=#787B86)

h2 = hline(80, "Upper Band 80 %", color=#787B86)
h3 = hline(100, "Upper Band 100 %", color=#787B86)


hm = hline(50, "50 band", color=#787B86)

fill(h1, h2, color=color.rgb(33, 150, 243, 90), title="Middle Background")

fill(h2, h3, color=color.new(color.red,85), title="Upper Background")

fill(h0, h1, color=color.new(color.green,85), title="Lower Background")
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68862784

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档