when i need to summ values from tuples of my security function i have an error "Cannot call 'operator +' with argument 'expr0'='trend_m5_s01'. An argument of 'int[]' type was used but a 'const int' is expected."
How can we fix this?
//@version=5
s01 = input.symbol('BTCUSDT', group = 'Symbols', inline = 's01')
res1 = input.timeframe('5', title='Timeframe 5 min')
screener_func() =>
sma50_5 = ta.sma(close, 50)
sma200_5 = ta.sma(close, 200)
trend_m5 = 0
trend_m5 := close < sma50_5 and close > sma200_5 or close > sma50_5 and close < sma200_5 ? 0 : close > sma50_5 and close > sma200_5 ? 1 : close < sma50_5 and close < sma200_5 ? -1 : na
sma50_15 = ta.sma(close, 150)
sma200_15 = ta.sma(close, 600)
trend_m15 = 0
trend_m15 := close < sma50_15 and close > sma200_15 or close > sma50_15 and close < sma200_15 ? 0 : close > sma50_15 and close > sma200_15 ? 1 : close < sma50_15 and close < sma200_15 ? -1 : na
sma50_30 = ta.sma(close, 300)
sma200_30 = ta.sma(close, 1200)
trend_m30 = 0
trend_m30 := close < sma50_30 and close > sma200_30 or close > sma50_30 and close < sma200_30 ? 0 : close > sma50_30 and close > sma200_30 ? 1 : close < sma50_30 and close < sma200_30 ? -1 : na
sma50_60 = ta.sma(close, 600)
sma200_60 = ta.sma(close, 2400)
trend_m60 = 0
trend_m60 := close < sma50_60 and close > sma200_60 or close > sma50_60 and close < sma200_60 ? 0 : close > sma50_60 and close > sma200_60 ? 1 : close < sma50_60 and close < sma200_60 ? -1 : na
sma50_120 = ta.sma(close, 1200)
sma200_120 = ta.sma(close, 4800)
trend_m120 = 0
trend_m120 := close < sma50_30 and close > sma200_30 or close > sma50_30 and close < sma200_30 ? 0 : close > sma50_30 and close > sma200_30 ? 1 : close < sma50_30 and close < sma200_30 ? -1 : na
sma50_240 = ta.sma(close, 2400)
sma200_240 = ta.sma(close, 9600)
trend_m240 = 0
trend_m240 := close < sma50_240 and close > sma200_240 or close > sma50_240 and close < sma200_240 ? 0 : close > sma50_240 and close > sma200_240 ? 1 : close < sma50_240 and close < sma200_240 ? -1 : na
sma50_720 = ta.sma(close, 7200)
sma200_720 = ta.sma(close, 28800)
trend_m720 = 0
trend_m720 := close < sma50_720 and close > sma200_720 or close > sma50_720 and close < sma200_720 ? 0 : close > sma50_720 and close > sma200_720 ? 1 : close < sma50_720 and close < sma200_720 ? -1 : na
[trend_m5, trend_m15, trend_m30, trend_m60, trend_m120, trend_m240, trend_m720]
[trend_m5_s01, trend_m15_s01, trend_m30_s01, trend_m60_s01, trend_m120_s01, trend_m240_s01, trend_m720_s01] = request.security_lower_tf(s01, res1, screener_func())
/// down here i have an issue when im trying to summ this values "Cannot call 'operator +' with argument 'expr0'='trend_m5_s01'. An argument of 'int[]' type was used but a 'const int' is expected."
s01_trend = ((trend_m5_s01 + trend_m15_s01 + trend_m30_s01 + trend_m60_s01 + trend_m120_s01 + trend_m240_s01 + trend_m720_s01)/ 7) * 100
//
plot(s01_trend)
We need to figure out why im cannot and how i can summ this values trend_m5_s01 + trend_m15_s01 + trend_m30_s01 + trend_m60_s01 + trend_m120_s01 + trend_m240_s01 + trend_m720_s01 from tuples of security function
request.security_lower_tf()
returns an array containing one element for each closed lower timeframe intrabar inside the current chart's bar.
request.security_lower_tf(symbol, timeframe, expression, ignore_invalid_symbol, currency) → array<type>
You are trying to sum arrays which you cannot do.
You need to access the elements of the array and sum them up. It depends on what you want to do.