【问题标题】:how to fix this error in the strategy script如何在策略脚本中修复此错误
【发布时间】:2020-01-29 16:55:56
【问题描述】:

帮我修复策略脚本中的错误 “脚本无法翻译自:|B|a:=n 。 在我看来,错误发生在第一个指标的最后一行。在我看来,这是一个积分器字符串。enter link description here 单独没有策略,指标编译没有问题。

strategy("Strategy long ", overlay=true)

//study("Trend Step")
length = input(50)
src = close
dev = stdev(src,length)*2
a = 0.
a := n < length ? src : src > nz(a[1],src) + dev ? src : src < nz(a[1],src) - dev ? src : a[1]

//study("Slowema")
slow_ema_period = input(20,"Slow EMA Period")
avg_price = input(hlc3)
smooth_length = input(5, minval=1)
fast_end = input(2.5,step=.5)
slow_end = input(20)
abs_noise = abs(avg_price - avg_price[1])
noise = sum(abs_noise, smooth_length)
signal = abs(avg_price - avg_price[smooth_length])
smooth = pow(iff(noise != 0, signal / noise, 0) * (2/(fast_end + 1) - 2/(slow_end + 1)) + 2/(slow_end + 1), 2) 
avg_ma = nz(avg_ma[1]) + smooth * (avg_price - nz(avg_ma[1]))
ha_symbol = heikinashi(tickerid)
ha_close = security(ha_symbol, period, avg_ma)
slow_ema = ema(ha_close,slow_ema_period)

plot(a,color=color.lime,linewidth=2,transp=0)
plot(slow_ema,color=yellow,linewidth=2,style=line)

//Strategy
longCondition =  crossover(a,slow_ema) 
closeCondition = crossunder(a,slow_ema)
strategy.entry("long",strategy.long,when = longCondition)
strategy.close("long",when = closeCondition)

【问题讨论】:

    标签: pine-script algorithmic-trading indicator


    【解决方案1】:

    坦率地说,你只是复制随机的代码片段,把它们放在一起,然后把结果扔到这里吗?我在您的脚本中看到了三种不同版本的 pine。当然,在这种方法之后,你会得到如此奇怪的错误。你能尊重其他人并编写自己的代码,或者至少学习一些有关 pine 编程的知识吗? 首先也是主要问题是冗余代码a = 0.。应该只是 a = n &lt; length ... etc

    第二个问题: color.lime 应该是 lime

    【讨论】:

    • 不,我不做任何在你看来毫无意义的事情,只是复制粘贴......作为一个初学者,我真的看到代码编写并遇到问题,然后寻求帮助
    • 为什么你会看到 3 个不同版本的 pine?只有3个版本
    • 感谢您的帮助!帮助编译。我很感激你!
    • 版本 3 的开头必须有 //@version=3。否则它是版本 1。color.lime - 是版本 4:在它之前颜色没有前缀 color.
    猜你喜欢
    • 2022-06-22
    • 1970-01-01
    • 2023-02-04
    • 1970-01-01
    • 2010-09-10
    • 2022-11-02
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多