简体   繁体   English

获取其他时间范围的指标值

[英]Geting indicator value for other timeframe

I am using pine-script to plot the distance from the open to daily Average True Range on an intraday chart.我正在使用 pine-script 在日内图表上绘制从开盘价到每日平均真实范围的距离。 However, when i use an intraday chart the value for atr is not calculated with daily values但是,当我使用日内图表时,atr 的值不是用每日值计算的

d_open = security(tickerid, "D", open)

atr_l1 = d_open - vatr
atrLow =plot(title='atr_l1', series=atr_l1, style=circles, color=lime)

This code plots the ATR based on selected time frame此代码根据选定的时间范围绘制 ATR

I would like to access the daily ATR regardless to selected timeframe无论选定的时间范围如何,我都想访问每日 ATR

dayAtr10() => atr(10)
dailyAtr = security(tickerid, "D", dayAtr10())

Thanks for any tips感谢您的任何提示

You need to pass all daily calculations to the security() call, and use security() in a way that will not repaint.您需要将所有日常计算传递给security()调用,并以不会重绘的方式使用security() See the PineCoders How to avoid repainting when using security() - PineCoders FAQ indicator for an explanation on how to use security() while avoiding repainting.请参阅 PineCoders 如何在使用 security() 时避免重绘 - PineCoders 常见问题指示器以获取有关如何在避免重绘的同时使用security()的说明。

This script shows both repainting and non-repainting methods of using security() .此脚本显示了使用security()重绘和非重绘方法。 If you leave it on a chart for a while, you will see the discrepancies between both.如果您将其留在图表上一段时间,您会看到两者之间的差异。

//@version=3
study("", "", true)
atrGap = open - atr(10)
d_openGap = security(tickerid, "D", atrGap)
plot(d_openGap, "d_openGap", red)
d_openGapNoRepaint = security(tickerid, "D", atrGap[1], lookahead = barmerge.lookahead_on)
plot(d_openGapNoRepaint, "d_openGap", green)

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM