以bar_index为源的模式条件出现ValueWhen() [英] Patterning condition occurrences valuewhen() with bar_index as source

查看:16
本文介绍了以bar_index为源的模式条件出现ValueWhen()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试发现一种条件模式(在本例中为Williams Fractals)。

根据伦普普的helpful answer/explanation here,我可以使用valuewhen()函数和bar_index变量作为源,给我提供了出现的位置!

但是,我一定是错误地应用了此技术,因为我无法绘制形状。

我要寻找的是交替的Fractals模式(向上/向下/向上);以下是我当前的代码片段:

uf_0_bar_index = valuewhen(upFractal, bar_index, 0)
df_0_bar_index = valuewhen(downFractal, bar_index, 0)
uf_1_bar_index = valuewhen(upFractal, bar_index, 1)
df_1_bar_index = valuewhen(downFractal, bar_index, 1)

pattern_order = uf_0_bar_index < df_0_bar_index and df_0_bar_index < uf_1_bar_index
plotshape(pattern_order, style=shape.triangleup, location=location.abovebar, offset=-n, color=color.orange, size = size.small)

例如,这应生成一个形状:

推荐答案

upFractal = high < high[1] and high[1] > high[2]
downFractal = low > low[1] and low[1] < low[2]

plotshape(upFractal, style = shape.triangleup, location = location.abovebar, offset = -1, color = color.green, size = size.normal)
plotshape(downFractal, style = shape.triangledown, location = location.belowbar, offset = -1, color = color.red, size = size.normal)

uf_0_bar_index = valuewhen(upFractal, bar_index, 0)
df_0_bar_index = valuewhen(downFractal, bar_index, 0)
uf_1_bar_index = valuewhen(upFractal, bar_index, 1)
df_1_bar_index = valuewhen(downFractal, bar_index, 1)

pattern_order = uf_0_bar_index > df_0_bar_index and df_0_bar_index > uf_1_bar_index
plotshape(pattern_order, style=shape.triangleup, location=location.abovebar, offset=-1, color=color.orange, size = size.small)
请记住,只有在确认最后一个upFractal时,才会出现向上/向下/向上的条件,在上面的代码中,这是在upFractal峰值之后的一个条形。如果您定义了具有多个右侧条的分形图,则在显示向上/向下/向上之前,它将使用该数量的条。

这篇关于以bar_index为源的模式条件出现ValueWhen()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆