Fisher 变换交叉时如何绘制箭头?
How to plot an arrow when Fisher transform crosses over?
每次 Fisher 变换交叉时,我都试图绘制一个箭头。到目前为止,我可以绘制显示上升趋势或下降趋势的箭头,但我不知道如何存储以前的状态,以便仅指示趋势的切换。
因此,当您创建新的 Fisher 变换时,您可以看到 2 个变量 fish1 和 fish2。每次以前 fish1 > fish2 和现在 fish1 < fish2 时,都应该绘制一个箭头。
下面是使用 plotshape() 的完整代码。
//@version=3
study(title="Fisher Transform", shorttitle="Fisher")
len = input(9, minval=1, title="Length")
high_ = highest(hl2, len)
low_ = lowest(hl2, len)
round_(val) => val > .99 ? .999 : val < -.99 ? -.999 : val
value = 0.0
value := round_(.66 * ((hl2 - low_) / max(high_ - low_, .001) - .5) + .67 * nz(value[1]))
fish1 = 0.0
fish1 := .5 * log((1 + value) / max(1 - value, .001)) + .5 * nz(fish1[1])
fish2 = fish1[1]
plotshape(fish1 > fish2, style=shape.arrowup, location=location.belowbar, color=green, size=size.small, text="Buy")
plotshape(fish1 < fish2, style=shape.arrowdown, location=location.belowbar, color=red, size=size.small, text="Sell")
hline(1.5, color=orange)
hline(0.75)
hline(0, color=orange)
hline(-0.75)
hline(-1.5, color=orange)
plot(fish1, color=blue, title="Fisher")
plot(fish2, color=orange, title="Trigger")
是否有函数允许我仅在条件 'is greater' 变为 'is lower' 时绘制箭头?
非常感谢!
crossover()
和 crossunder()
是您要查找的函数。
crossover
The x
-series is defined as having crossed over y
-series if the
value of x
is greater than the value of y
and the value of x
was
less than the value of y
on the bar immediately preceding the
current bar.
crossunder
The x
-series is defined as having crossed under y
-series if the
value of x
is less than the value of y
and the value of x
was
greater than the value of y
on the bar immediately preceding the
current bar.
plotshape(crossover(fish1, fish2), style=shape.arrowup, location=location.belowbar, color=green, size=size.small, text="Buy")
plotshape(crossunder(fish1, fish2), style=shape.arrowdown, location=location.belowbar, color=red, size=size.small, text="Sell")
每次 Fisher 变换交叉时,我都试图绘制一个箭头。到目前为止,我可以绘制显示上升趋势或下降趋势的箭头,但我不知道如何存储以前的状态,以便仅指示趋势的切换。
因此,当您创建新的 Fisher 变换时,您可以看到 2 个变量 fish1 和 fish2。每次以前 fish1 > fish2 和现在 fish1 < fish2 时,都应该绘制一个箭头。 下面是使用 plotshape() 的完整代码。
//@version=3
study(title="Fisher Transform", shorttitle="Fisher")
len = input(9, minval=1, title="Length")
high_ = highest(hl2, len)
low_ = lowest(hl2, len)
round_(val) => val > .99 ? .999 : val < -.99 ? -.999 : val
value = 0.0
value := round_(.66 * ((hl2 - low_) / max(high_ - low_, .001) - .5) + .67 * nz(value[1]))
fish1 = 0.0
fish1 := .5 * log((1 + value) / max(1 - value, .001)) + .5 * nz(fish1[1])
fish2 = fish1[1]
plotshape(fish1 > fish2, style=shape.arrowup, location=location.belowbar, color=green, size=size.small, text="Buy")
plotshape(fish1 < fish2, style=shape.arrowdown, location=location.belowbar, color=red, size=size.small, text="Sell")
hline(1.5, color=orange)
hline(0.75)
hline(0, color=orange)
hline(-0.75)
hline(-1.5, color=orange)
plot(fish1, color=blue, title="Fisher")
plot(fish2, color=orange, title="Trigger")
是否有函数允许我仅在条件 'is greater' 变为 'is lower' 时绘制箭头?
非常感谢!
crossover()
和 crossunder()
是您要查找的函数。
crossover
The
x
-series is defined as having crossed overy
-series if the value ofx
is greater than the value ofy
and the value ofx
was less than the value ofy
on the bar immediately preceding the current bar.crossunder
The
x
-series is defined as having crossed undery
-series if the value ofx
is less than the value ofy
and the value ofx
was greater than the value ofy
on the bar immediately preceding the current bar.
plotshape(crossover(fish1, fish2), style=shape.arrowup, location=location.belowbar, color=green, size=size.small, text="Buy")
plotshape(crossunder(fish1, fish2), style=shape.arrowdown, location=location.belowbar, color=red, size=size.small, text="Sell")