Cannot call 'ta.sma' with argument 'length'='smoothD'. An argument of 'input float' type was used but a 'series int' is expected

64 views Asked by At

Totally new here. Can someone help decipher the following error? I am trying to plot the following information on a graph:

Cannot call 'ta.sma' with argument 'length'='smoothD'. An argument of 'input float' type was used but a 'series int' is expected.

//@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)
1

There are 1 answers

1
vitruvius On BEST ANSWER

The error message is pretty clear, isn't it? You need to use an int but you are passing a float.

There is a difference between int and float. You can read this to get to know with the data types in pinescript.

You float inputs do not make any sense as float as they are lengths. Change them to int and you will be good.