首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当满足几个条件时,如何对一个条形进行着色?

当满足几个条件时,如何对一个条形进行着色?
EN

Stack Overflow用户
提问于 2022-10-29 04:42:56
回答 1查看 34关注 0票数 0

嗨,我正在努力编码一个指示灯,如果10到12支蜡烛之前我们有一个摇摆高(SH)和当前的RSI是超卖的当前条颜色。此外,如果10至12巴之前,我们有一个摆动低点(SL)和当前的RSI是超买。

代码语言:javascript
运行
复制
SH = open[5] < close[5] and open[4] < close[4] and open[3] < close[3] and open[2] > close[2] and open[1] > close[1] and open[0] > close[0]

SL = open[5] > close[5] and open[4] > close[4] and open[3] > close[3] and open[2] < close[2] and open[1] < close[1] and open[0] < close[0]

我对这个问题一无所知

EN

回答 1

Stack Overflow用户

发布于 2022-10-29 21:52:05

代码语言:javascript
运行
复制
//@version=5
indicator("swing/rsi", overlay = true)

swing_start_lb = input.int(10, title = "Start of Swing lookback")
swing_end_lb = input.int(12, title ="End of Swing lookback" )

ob = input.float(80, title = "RSI OB")
os = input.float(20, title = "RSI OS")

SH = open[5] < close[5] and open[4] < close[4] and open[3] < close[3] and open[2] > close[2] and open[1] > close[1] and open[0] > close[0]
SL = open[5] > close[5] and open[4] > close[4] and open[3] > close[3] and open[2] < close[2] and open[1] < close[1] and open[0] < close[0]
plotshape(SH, title = "Swing High", style = shape.triangledown, location = location.abovebar, color = color.red)
plotshape(SL, title = "Swing Low", style = shape.triangleup, location = location.belowbar, color = color.green)

r = ta.rsi(close, 14)
bgcolor(r >= ob ? color.new(color.red, 80) : r <= os ? color.new(color.green, 80) : #00000000)

bool SH_RSIOS_cond = false
bool SL_RSIOB_cond = false

for i = swing_start_lb to swing_end_lb
    if SH[i] and r <= os
        SH_RSIOS_cond := true
    if SL[i] and r >= ob
        SL_RSIOB_cond := true 

barcolor(SH_RSIOS_cond ? color.aqua : na)
barcolor(SL_RSIOB_cond ? color.fuchsia : na)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74242866

复制
相关文章

相似问题

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