如何在 tradingview 上自动绘制目标
how to automatic plot targets on tradingview
我正在 tradingview 上尝试自动绘图目标,就像这张图片
,
但是我失败了,TP会Recurring几次。
谁能帮帮我?
plotshape( (close>TP1_value) , title="TP1_Reached", style=shape.arrowup, location=location.belowbar, color=green, transp=0, text="TP1_Reached", textcolor=green, size=size.large)
您的问题是,close>TP1_value
对于多个柱是正确的。如果只想绘制一次,可以使用变量。
//@version=4
study("My Script", overlay=true)
TP1_value = input(title="Take Profit Price", defval=10000)
var isTP1reached = false // Use this variable to see if TP1 hass already been reached
takeProfit1 = not isTP1reached and (close > TP1_value) // If not already reached TP1 and TP condition is true
if (takeProfit1)
isTP1reached := true
plotshape(series=takeProfit1, title="Take Profit 1", text="Take Profit 1", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
从上图可以看出,它只绘制了一次。当然你需要根据自己的需要重新设置变量才能再次使用。
我正在 tradingview 上尝试自动绘图目标,就像这张图片
但是我失败了,TP会Recurring几次。
谁能帮帮我?
plotshape( (close>TP1_value) , title="TP1_Reached", style=shape.arrowup, location=location.belowbar, color=green, transp=0, text="TP1_Reached", textcolor=green, size=size.large)
您的问题是,close>TP1_value
对于多个柱是正确的。如果只想绘制一次,可以使用变量。
//@version=4
study("My Script", overlay=true)
TP1_value = input(title="Take Profit Price", defval=10000)
var isTP1reached = false // Use this variable to see if TP1 hass already been reached
takeProfit1 = not isTP1reached and (close > TP1_value) // If not already reached TP1 and TP condition is true
if (takeProfit1)
isTP1reached := true
plotshape(series=takeProfit1, title="Take Profit 1", text="Take Profit 1", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
从上图可以看出,它只绘制了一次。当然你需要根据自己的需要重新设置变量才能再次使用。