![](/img/trans.png)
[英]How pivothigh() and pivotlow() function work on Tradingview Pinescript?
[英]pinescript get index of pivothigh
我想獲取最后一次出現 pivothigh 的條形索引,以便我可以將它用於 plot 一個從該索引開始的指標。 對pinescript不熟悉,參考文獻有限
您可以使用內置的barssince
function 並在歷史參考運算符[]
中使用結果
barssincePhigh = barssince(phigh)
barssincePlow = barssince(plow)
但是,默認情況下,您的樞軸在 10 個柱后觸發,將leftbars
值添加到 barsisnce 結果以顯示高/低 pivot:
//@version=4
study("Pivot Prices", overlay=true)
leftbars = input(10, minval=1, title='Bars to the left')
rightbars = input(10, minval=1, title='Bars to the right')
phigh = pivothigh(high, leftbars, rightbars)
plow = pivotlow(low, leftbars, rightbars)
barssincePhigh = barssince(phigh) + leftbars
barssincePlow = barssince(plow) + leftbars
if phigh
label1 = label.new(bar_index[barssincePhigh], high[barssincePhigh], text=tostring(high[barssincePhigh]), style = label.style_labeldown, color = color.orange)
if plow
label2 = label.new(bar_index[barssincePlow], low[barssincePlow], text=tostring(low[barssincePlow]), style = label.style_labelup, color = color.green)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.