我是 Pine 的新手,如果要处理选择输入,则无法获得以下内容
// Backtest
entrySource = input(title="Enter On", defval = "Buy Big Green", options=["Buy Small Green", "Buy Big Green", "Buy Big Green Div"])
exitSource = input(title="Exit On", defval = "Sell Big Red", options=["Sell Small Red", "Sell Big Red", "Sell Big Red Div"])
entry = if entrySource == "Buy Small Green"
wtCross and wtCrossUp
else if entrySource == "Buy Big Green"
entry = buySignal
else if entrySource == "Sell Small Red"
entry = buySignalDiv
else
na
exit = if exitSource == "Buy Small Green"
wtCross and wtCrossDown
else if entrySource == "Sell Big Red"
buySignal
else if entrySource == "Sell Small Red"
buySignalDiv
else
na
我得到了经典的
line 489: Mismatched input 'wtCross' expecting 'end of line without line continuation'.
错误,但我不知道为什么。
你在格式化 if else if 表达式时犯了一个小错误,尝试像这里一样删除缩进:
//@version=4
study("Backtest", overlay=true)
entrySource = input(title="Enter On", defval = "Buy Big Green", options=["Buy Small Green", "Buy Big Green", "Buy Big Green Div"])
exitSource = input(title="Exit On", defval = "Sell Big Red", options=["Sell Small Red", "Sell Big Red", "Sell Big Red Div"])
wtCross = true, wtCrossUp = true, wtCrossDown = true, buySignal = true, buySignalDiv = true
entry = if entrySource == "Buy Small Green"
wtCross and wtCrossUp
else if entrySource == "Buy Big Green"
buySignal
else if entrySource == "Sell Small Red"
buySignalDiv
else
na
exit = if exitSource == "Buy Small Green"
wtCross and wtCrossDown
else if entrySource == "Sell Big Red"
buySignal
else if entrySource == "Sell Small Red"
buySignalDiv
else
na
plot(entry ? 1 : 0)
plot(exit ? 1 : 0)