如果标志已经指示了long,则不应该有指示long的新标志。如果标志没有指示长,则计算表达式
longCondition = if (strategy.long) ? false: (rsi<30) and (close>moving_avg)
shortCondition = if (strategy.short) ? false: (rsi>70) and (close<moving_avg)处理脚本..。
第30行:不匹配的输入'shortCondition‘期望’行的末尾没有行连续‘
发布于 2019-10-15 05:33:17
我认为这是一个指标,而不是一个战略。因为您可以使用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)

https://stackoverflow.com/questions/58383816
复制相似问题