gpt4 book ai didi

pine-script - Pine Script 初学者,plotshape

转载 作者:行者123 更新时间:2023-12-04 02:44:42 29 4
gpt4 key购买 nike

寻找解决方法,不能以这种方式使用 plotshape,因为它在本地范围内不起作用。

//@version=3
study("MA test ", overlay=true)
FastMA = sma(close, 9)
SlowMA = sma(close, 15)
Diff = FastMA - SlowMA
if Diff > 0
plotshape(Diff, style=shape.arrowup, location=location.belowbar, color=green)

最佳答案

您可以直接将您的条件应用到 series plot()的论据函数(也适用于 color 参数)。
我还添加了另一个 plotshape()使用 crossover()在其 series它只在 FastMA 穿过 SlowMA(橙色三角形)时绘制三角形。我认为它将来可能对你有用:)

//@version=3
study("MA test ", overlay=true)
FastMA = sma(close, 9)
SlowMA = sma(close, 15)
Diff = FastMA - SlowMA

plot(series=FastMA, title="FastMA", color=color.green, linewidth=3)
plot(series=SlowMA, title="SlowMA", color=color.red, linewidth=3)
bgcolor(color=Diff > 0 ? green : red)
plotshape(series=Diff > 0, style=shape.arrowup, location=location.belowbar, color=color.green, size=size.normal)
plotshape(series=crossover(FastMA, SlowMA), style=shape.triangledown, location=location.abovebar, color=color.orange, size=size.normal)
enter image description here

关于pine-script - Pine Script 初学者,plotshape,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52876550/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com