2017-09-22 52 views
1

パインエディタには、線をプロットするための組み込み関数(サポート線、トレンド線など)はまだありません。 線を引く直接的または間接的な方法が見つかりませんでした。 私は、任意のアイデアや提案Pineスクリプト(Tradingview)で線を描く方法は?

draw_line(price1, time1,price2, time2) 

(のみ例えば)以下のように見える機能を構築したいですか?

答えて

2

残念ながら、私はこれが提供したいとは思っていません。 4年前から届かなかった有望な投稿に気づいた。他の唯一の方法は、関連性のない部分を非表示にする線のプロットを線で近似することによって、計算を含むように見えます。 exampleについては

enter image description here

次に、あなただけの緑の部分を取得するためにnaredを交換しようとすることができます:

... 
c = close >= open ? lime : red 
plot(close, color = c) 

はこのような何かを生成します。私はいくつかのより多くの実験を行ってきた

例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) 

結果は、かなりいいですけど:どうやらパインはそう唯一の方法は、このように、ラインのポイントスロープ式を使用するように見えるので、あなたも、関数内でプロットを置くことができない不自由さ使用するにはあまりにも不便です。 enter image description here

関連する問題