【问题标题】:Geting indicator value for other timeframe获取其他时间范围的指标值
【发布时间】:2019-09-03 22:56:30
【问题描述】:

我正在使用 pine-script 在日内图表上绘制从开盘价到每日平均真实范围的距离。但是,当我使用日内图表时,atr 的值不是用每日值计算的

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

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

此代码根据选定的时间范围绘制 ATR

无论选择的时间范围如何,我都想访问每日 ATR

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

感谢任何提示

【问题讨论】:

    标签: trading pine-script


    【解决方案1】:

    您需要将所有日常计算传递给security() 调用,并以不会重新绘制的方式使用security()。请参阅 PineCoders How to avoid repainting when using security() - PineCoders FAQ 指示器,了解如何在避免重绘的同时使用 security()

    此脚本显示了使用security() 的重绘和非重绘方法。如果你把它放在图表上一段时间,你会看到两者之间的差异。

    //@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)
    

    【讨论】:

    • 谢谢,这正是我想要的。如何将此标记为答案?
    • 点击上/下投票箭头下方的复选标记以获得答案。
    猜你喜欢
    • 2022-12-04
    • 2012-10-19
    • 2022-12-03
    • 1970-01-01
    • 1970-01-01
    • 2019-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多