满足条件时指示器中的背景颜色

发布于 2025-01-21 18:38:10 字数 1705 浏览 3 评论 0原文

在此指标结合了Walter Bresserts Double随机和RSI中,我一直在尝试添加背景颜色。

当满足“短”条件时,我希望在“长”条件下满足“长”条件时变成绿色:

long =((RSI< 15或RSI [1]< 15或RSI [2]< 15) and(dds10< 25))

short =((RSI> 85或RSI [1]> 85或RSI [2]> 85)> 85)和(DDS10> 85))

是否有人知道该怎么做?

提前致谢, 菲利普

//@version=5
indicator('RSI & DT Bressert')
HighlightBreaches = input(true, title='Highlight Oversold/Overbought?')
period = input.int(defval=13, title='Period', minval=1, maxval=16)
top = 85
bot = 25

len = input.int(2, minval=1, title='Length')
src = input(close, 'Source')
up = ta.rma(math.max(ta.change(src), 0), len)
down = ta.rma(-math.min(ta.change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
plot(rsi, 'RSI', color=color.new(#C0C0C0, 0))

period10 = input(title='Periodes', defval=10)
period5 = input(title='Periodes', defval=5)

stochastic10 = ta.ema((close - ta.lowest(low, period10)) / (ta.highest(high, period10) - ta.lowest(low, period10)) * 100, 3)
dds10 = ta.ema((stochastic10 - ta.lowest(stochastic10, period10)) / (ta.highest(stochastic10, period10) - ta.lowest(stochastic10, period10)) * 100, 3)

stochastic5 = ta.ema((close - ta.lowest(low, period5)) / (ta.highest(high, period5) - ta.lowest(low, period5)) * 100, 3)
dds5 = ta.ema((stochastic5 - ta.lowest(stochastic5, period5)) / (ta.highest(stochastic5, period5) - ta.lowest(stochastic5, period5)) * 100, 3)

hline(title='OB', price=top, color=color.black)
hline(title='OS', price=bot, color=color.black)

plot(series=dds10, color=dds10[1] < dds10 ? color.green : color.red, linewidth=2)
plot(series=dds5, color=dds5[1] < dds5 ? color.blue : color.navy, linewidth=2)

I have been trying to add background colors when certain conditions are met in this indicator that combines Walter Bresserts double stochastic and the RSI.

I want the background color to turn green when "long" conditions are met and red when "short" conditions are met:

long = ((rsi < 15 or rsi[1] < 15 or rsi[2] < 15) and (dds10 < 25))

short = ((rsi > 85 or rsi[1] > 85 or rsi[2] > 85) and (dds10 > 85))

Does anyone here know how to do that?

Thanks in advance,
Philip

//@version=5
indicator('RSI & DT Bressert')
HighlightBreaches = input(true, title='Highlight Oversold/Overbought?')
period = input.int(defval=13, title='Period', minval=1, maxval=16)
top = 85
bot = 25

len = input.int(2, minval=1, title='Length')
src = input(close, 'Source')
up = ta.rma(math.max(ta.change(src), 0), len)
down = ta.rma(-math.min(ta.change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
plot(rsi, 'RSI', color=color.new(#C0C0C0, 0))

period10 = input(title='Periodes', defval=10)
period5 = input(title='Periodes', defval=5)

stochastic10 = ta.ema((close - ta.lowest(low, period10)) / (ta.highest(high, period10) - ta.lowest(low, period10)) * 100, 3)
dds10 = ta.ema((stochastic10 - ta.lowest(stochastic10, period10)) / (ta.highest(stochastic10, period10) - ta.lowest(stochastic10, period10)) * 100, 3)

stochastic5 = ta.ema((close - ta.lowest(low, period5)) / (ta.highest(high, period5) - ta.lowest(low, period5)) * 100, 3)
dds5 = ta.ema((stochastic5 - ta.lowest(stochastic5, period5)) / (ta.highest(stochastic5, period5) - ta.lowest(stochastic5, period5)) * 100, 3)

hline(title='OB', price=top, color=color.black)
hline(title='OS', price=bot, color=color.black)

plot(series=dds10, color=dds10[1] < dds10 ? color.green : color.red, linewidth=2)
plot(series=dds5, color=dds5[1] < dds5 ? color.blue : color.navy, linewidth=2)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌无敌 2025-01-28 18:38:10

您可以在代码末尾添加类似的内容。它使用 bgcolor()

long = ((rsi < 15 or rsi[1] < 15 or rsi[2] < 15) and (dds10 < 25))
short = ((rsi > 85 or rsi[1] > 85 or rsi[2] > 85) and (dds10 > 85))
bgcolor(long ? color.green : short ? color.red : na)

You can add something like this at the end of your code. It uses bgcolor()

long = ((rsi < 15 or rsi[1] < 15 or rsi[2] < 15) and (dds10 < 25))
short = ((rsi > 85 or rsi[1] > 85 or rsi[2] > 85) and (dds10 > 85))
bgcolor(long ? color.green : short ? color.red : na)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文