【问题标题】:In Pine-Script, how do I code two conditions for my entry?在 Pine-Script 中,我如何为我的条目编写两个条件?
【发布时间】:2021-09-06 06:44:33
【问题描述】:

有人可以帮忙吗,因为我需要进入条件才能将 BraidFilter 指标包含到我的策略中。我只需要在绿条越过过滤线时做多交易,当红条越过过滤线时需要做空。这就是我所做的,但它不起作用,并且我收到大量错误消息: 请帮忙。谢谢。

//-- Braid Filter   
ma01 = ma(maType, close, Period1)
ma02 = ma(maType, open, Period2)
ma03 = ma(maType, close, Period3)

max  = max(max(ma01, ma02), ma03)
min  = min(min(ma01, ma02), ma03)
dif  = max - min

filter = atr(14) * PipsMinSepPercent / 100

//-- Plots/=
//BraidColor = ma01 > ma02 and dif > filter ? color.green : ma02 > ma01 and dif > filter ? color.red : color.gray

//plot(dif, "Braid", BraidColor, 5, plot.style_columns)
//plot(filter, "Filter", color.blue, 2, plot.style_line)
//bgcolor(BraidColor)

// Condition
C1Price1 = 0.0
C1Price2 = 0.0
C1Price1 := ? ma01 > ma02 and dif > filter
C1Price2 := ? ma02 > ma01 and dif > filter

c1Cross_Long    =  crossover (C1Price1,C1Price2) and C1Price1 > filter
c1Cross_Short   =  crossover (C1Price1,C1Price2) and C1Price2 > filter 

【问题讨论】:

    标签: conditional-statements pine-script algorithmic-trading trading multiple-conditions


    【解决方案1】:

    该代码中缺少一些东西,首先您必须使用策略定义脚本,然后定义 maType 变量,除此之外:

    C1Price1: =**?** ma01> ma02 and dif> filter
    C1Price2: =**?** ma02> ma01 and dif> filter
    

    在“?”之前必须有条件满足,我觉得那里删了,改正后要写词条。

    【讨论】:

    • 我实际上只是从上面的“Braidcolor”行中复制了这些行 //plots,认为它会起作用。
    • 这是我整个策略的一部分,所以“study()”位于代码上方,我发布的只是指标。所以我需要寻找条件规则?
    猜你喜欢
    • 1970-01-01
    • 2019-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-07
    • 1970-01-01
    • 2012-08-15
    相关资源
    最近更新 更多