1
鬆編輯器仍然沒有內置函數來繪製線(如支持線,趨勢線)。 我找不到任何直接或間接的方法來繪製線條。 我想建立功能看起來像下面(例如只)如何在Pine腳本(Tradingview)中繪製線條?
draw_line(price1, time1,price2, time2)
任何意見或建議?
鬆編輯器仍然沒有內置函數來繪製線(如支持線,趨勢線)。 我找不到任何直接或間接的方法來繪製線條。 我想建立功能看起來像下面(例如只)如何在Pine腳本(Tradingview)中繪製線條?
draw_line(price1, time1,price2, time2)
任何意見或建議?
不幸的是,我不認爲這是他們想提供的東西。注意到4年前的幾個有前途的帖子,從來沒有出現過。唯一的另一種方式,似乎涉及到一些計算,通過用一些線圖來近似你的線,在那裏隱藏不相關的部分。
對於example:
...
c = close >= open ? lime : red
plot(close, color = c)
會產生這樣的:
然後,你可以嘗試用na
更換red
只拿到綠色部分。
例2
我做了一些更多的實驗。顯然,鬆是這樣殘廢,你甚至不能把一個情節功能,所以唯一的辦法似乎是用點斜率公式爲一條線,像這樣:
//@version=3
study(title="Simple Line", shorttitle='AB', overlay=true)
P1x = input(5744)
P1y = input(1.2727)
P2x = input(5774)
P2y = input(1.2628)
plot(n, color=na, style=line) // hidden plot to show the bar number in indicator
// point slope
m = - (P2y - P1y)/(P2x - P1x)
// plot range
AB = n < P1x or n > P2x ? na : P1y - m*(n - P1x)
LA = (n == P1x) ? P1y : na
LB = (n == P2x) ? P2y : na
plot(AB, title="AB", color=#ff00ff, linewidth=1, style=line, transp=0)
plotshape(LA, title='A', location=location.absolute, color=silver, transp=0, text='A', textcolor=black, style=shape.labeldown)
plotshape(LB, title='B', location=location.absolute, color=silver, transp=0, text='B', textcolor=black, style=shape.labelup)