无法使用参数“length”=“smoothD”调用“ta.sma”。使用了“输入浮点”类型的参数,但需要“系列整数”

问题描述 投票:0回答:1

这里是全新的。有人可以帮助破译以下错误吗?我正在尝试在图表上绘制以下信息:

无法使用参数“length”=“smoothD”调用“ta.sma”。使用了“输入 float”类型的参数,但需要“series int”。

//@version=5
strategy("FingersCrossed Signals", overlay=true)

//ta.ema
ema3 = ta.ema(close,9)
ema4 = ta.ema(close,21)
long_ema = ta.crossover(ema3,ema4)
short_ema = ta.crossover(ema4,ema3)

//stochrsi
smoothK = input.float(3, minval=1)
smoothD = input.float(3, minval=1)
lengthRSI = input.float(14, minval=1)
lengthStoch = input.float(14, minval=1)
src = input(close, title="RSI Source")

rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)

data = (60-k[1])/2
data2 = (k[1]-40)/2

long_stoch = k[1] >= d[1] and k[2] <= d[2] and k <= 60 and k >= 10
short_stoch = k[1] <= d[1] and k[2] >= d[2] and k >= 40 and k <= 95

//entries
if (long_ema) 
    strategy.entry("buy", strategy.long)
if (ema3 > ema4 and long_stoch) // ema3 > ema4 means that crossover was already and uptrend is continuing 
    strategy.entry("buy+1", strategy.long)
if (short_ema) 
    strategy.entry("sell", strategy.short)
pine-script floating
1个回答
0
投票

错误信息很清楚,不是吗?您需要使用

int
,但您传递的是
float

int
float
之间有区别。您可以阅读this来了解pinescript中的数据类型。

您的

float
输入与
float
一样没有任何意义,因为它们是
length
。将它们更改为
int
,你就会很好。

© www.soinside.com 2019 - 2024. All rights reserved.