Averaging across multiple arrays?


I am converting a script in Pinescript to AFL..and involves arithmetic mean and moving average. Below is my attempt. Am I on the right track?

myValue = linreg(close - avg(avg(highest(high, myLength), lowest(low, myLength)),sma(close,myLength)), myLength,0)

Where myValue is linear regression array.. and close, high, low are also arrays

myValue = LinearReg(close - ma(highest(high) +lowest(low)+close, myLength), myLength)

my latest thought.. not sure this will work across arrays

myValue = LinearReg(close - (((hhv(high,myLength) +lllv(low,myLength))/2)+ma(close,myLength))/3, myLength)

Simply make it it readable by creating variables.

myLength = 20;
avg1 = 0.5*(HHV(H, myLength) + LLV(L, myLength));
avg2 = 0.5*(avg1+MA(C,myLength));
myValue = LinearReg(C - avg2, myLength);
Plot(myValue, "myValue", colorRed);
1 Like

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