簡體   English   中英

如何使用 pine 腳本在不同的時間范圍內顯示相同的值?

[英]How to display same value in different timeframes with pine script?

這是代碼片段:

Length = (20)
dhigh = request.security(syminfo.tickerid, "1D", high) 
dlow = request.security(syminfo.tickerid, "1D", low)
ADR = request.security(syminfo.tickerid, "1D", 100 * (ta.sma(dhigh/dlow, Length) - 1))

我稍后會在表中顯示 ADR 值。 它在所有時間范圍內都應該是一個常數值,但事實並非如此 - 例如,它在所有低於每日的時間范圍內都是相同的,但不是每周。

我如何使其在所有時間范圍內保持不變? 請幫忙。

我閱讀了手冊,但找不到答案。 我也在網上搜索了類似的問題,但找不到嘗試的想法。

security() function 旨在請求高於當前圖表時間范圍的時間范圍的數據。

如果您想從較低的時間范圍內獲取數據,您應該使用request.security_lower_tf() function。

例子:

//@version=5
indicator("`request.security_lower_tf()` Example")
float travel = math.abs(high - low)
float[] ltfTravelArray = request.security_lower_tf(syminfo.tickerid, "1", travel)
float volatility = nz(array.sum(ltfTravelArray) / travel)
plot(volatility)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM