如果该标志已经指示长,则不应有新的指示长的标志。如果标志不指示长计算表达式
longCondition = if (strategy.long) ? false: (rsi<30) and (close>moving_avg)
shortCondition = if (strategy.short) ? false: (rsi>70) and (close<moving_avg)
处理脚本...
第 30 行:输入“shortCondition”不匹配,期望“行结束”
没有续行'
我认为这是一个指标而不是策略。因为您可以使用以下命令配置策略中同一方向的条目数量:pyramiding
范围。默认值为 0,因此如果这是一种策略并且您没有更改金字塔参数,那么它应该不是问题。
对于指标,您可以使用如下变量:
//@version=4
study("My Script", overlay=true)
var isLong = false
var isShort = false
rsi = rsi(close, 14)
moving_avg = ema(close, 9)
buySignal = not isLong and (rsi<50) and (close>moving_avg) // Buy only if we are not already long
sellSignal = not isShort and (rsi>50) and (close<moving_avg) // Sell only if we are not already short
if buySignal
isLong := true
isShort := false
if sellSignal
isLong := false
isShort := true
plotshape(series=buySignal, title="BUY", text="BUY", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(series=sellSignal, title="SELL", text="SELL", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)