【问题标题】:how to write pine script for adx above 25?如何为 25 岁以上的 adx 编写 pine 脚本?
【发布时间】:2021-04-07 13:45:12
【问题描述】:

我有 ema 交叉策略,但我希望我的订单仅在 adx 高于 25 时执行。我尝试使用 pinecript 在交易视图中执行此操作,但失败了。所以,我需要仅在 adx 高于 25 时执行的 pine 脚本。

【问题讨论】:

    标签: pine-script


    【解决方案1】:

    您需要像我们在此处使用cond 所做的那样,根据您的条件定义一个布尔变量,然后您可以使用它来有条件地或在您的脚本逻辑中进行绘图:

    //@version=4
    study(title="Directional Movement Index", shorttitle="DMI", format=format.price, precision=4)
    len = input(17, minval=1, title="DI Length")
    lensig = input(14, title="ADX Smoothing", minval=1, maxval=50)
    [_, _, adx] = dmi(len, lensig)
    plot(adx, color=color.red, title="ADX")
    hline(25)
    
    cond = adx > 25
    bgcolor(cond ? color.silver : na)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多