繁体   English   中英

不匹配的输入“strategy.entry”期望“没有行继续的行尾”我无法清除交易视图 cs 中的错误

[英]mismatched input 'strategy.entry' expecting 'end of line without line continuation' I cant clear error in trading view cs

嗨,我似乎可以修复错误

策略(“Recon EMA CROS RSI 40”,shorttittle =“EMA X RSI”,overlay=true,inital_capital = 10,default_qty_value = 100,default_QTY_TYPE = strategy.percent_of_equity,commision_value = 0.08)

// Input
EMA1 = input(title="fast EMA", type=input.integer, defval=9)
EMA2 = input(title="Slow EMA", type=input.integer, defval=24)

//Calculation
fastEMA = ema(close, EMA1)
slowEMA = ema(close, EMA2)

//Strategy
goLongCondition1 = crossover(fastEMA, slowEMA)
goLongCondition2 = (rsi(close,9) > 40)
exitCondition1 = crossover(slowEMA, fastEMA)
exitCondition2 = (rsi(close,9) < 40)
inTrade = strategy.position_size > 0
notOnTrade = strategy.position_size <= 0
timePeriod = time >= timestamp(system.timezone, 2023, 01, 01, 0, 0)
if (timePeriod and goLongCondition1 and goLongCondition2 and notOnTrade)
     strategy.entry("long", strategy.long, qty=default_qty_value, qtytype = default_QTY_TYPE, when=notOnTrade)
     stoploss = low * .9
     strategy.exit("exit", "long", stop=stoploss, when=notOnTrade)
if (exitCondition1 and exitCondition2 and inTrade)
     strategy.close("long")

//PLOT
plot(fastEMA, color=color.yellow)
plot(slowEMA, color=color.blue)
bgcolor(notOnTrade ? color.red : color.green)

在 pinescript 中,您必须遵守 if 命令行后的 4 个空格。
在您的代码中,有 5 个空格,这是错误的根源。
您应该将 2 if 块替换为:

if (timePeriod and goLongCondition1 and goLongCondition2 and notOnTrade)
    strategy.entry("long", strategy.long, qty=default_qty_value, qtytype = default_QTY_TYPE, when=notOnTrade)
    stoploss = low * .9
    strategy.exit("exit", "long", stop=stoploss, when=notOnTrade)
if (exitCondition1 and exitCondition2 and inTrade)
    strategy.close("long")

但是你的代码和其他几个错误一样。 请在出现时更正它们,不要犹豫,提出另一个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM