how to get average across multiple arrays?

Hello, I'm trying to convert following pinescript code to AFL

avg(avg(highest(high, myLen), lowest(low, myLen)),sma(close,myLen))

My poor attempt below.. anybody know how to do average across multiple arrays as above?

ma(highest(high)+lowest(low)+close, myLen)

Thanks in advance

I dont know if i understood it correctly but this is my attempt.

myLen = 10; // some length
myAvg = ( HHV(High, myLen) + LLV(Low, myLen) + MA(Close, myLen) ) / 3;

Average of Arrays is Sum of Arrays divided by the number of Arrays.

Why do you create duplicates?
It exists thread and response already


And no,

avg(avg(x+y)+z) is not the same as (x+y+z)/3

It is shocking that people can not even master basic math.

How on earth are this one:

(x+y+z) / 3 = (x+y)/3 + z/3

and this one

(x+y+z) / 2 = (x+y)/2 + z/2

supposed to be the same ones as this one (the looked for one):

((x+y)/2+z) / 2 = (x+y)/4 + z/2

Guys, this is elementary school math.

Q.E.D.

So what do you see that is not there?

2 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.