I decided to explore the recent ARRAY support by ProRealTine v11 and I want to share my work.
I modified the Meander Bands indicator (see v10.3 at https://www.prorealcode.com/prorealtime-indicators/meander-bands-thomas-stridsman/).
It used just 5 periods because arrays were not supported in v10.3, thus making adding manual periods time consuming, tiring and error prone. Now I used the same 5 periods to compare the two, to make sure they both yield the same results.
You can set more periods, if needed:
// Meander Bands by Thomas Stridsman
//
// https://www.prorealcode.com/prorealtime-indicators/meander-bands-thomas-stridsman/
//
// March 3, 2020: modified to use ARRAYS
//
//ONCE Periods = 5
//ONCE Deviations = 2
ONCE Middle = 0
ONCE MeanderHI = 0
ONCE MeanderLO = 0
MyAvg = 0
MyVar = 0
StDev = 0
FOR i = 0 TO (Periods - 1)
$barO[i] = (Open[i] - close[i+1]) / close[i+1]
$barH[i] = (High[i] - close[i+1]) / close[i+1]
$barL[i] = (Low[i] - close[i+1]) / close[i+1]
$barC[i] = (Close[i]- close[i+1]) / close[i+1]
//-------------- average price --------------------------------------
Avg = ($barO[i] + $barH[i] + $barL[i] + $barC[i]) / 4
MyAvg = MyAvg + Avg
NEXT
MyAvg = MyAvg / Periods
//-------------- calculation of standard deviation ------------------
FOR i = 0 TO (Periods - 1)
MyVar = MyVar + ((square($barO[i] - MyAvg) + square($barH[i] - MyAvg) + square($barL[i] - MyAvg) + square($barC[i] - MyAvg)) / 4)
NEXT
//
StDev = SQRT(MyVar / Periods)
//
Middle = close * (1 + MyAvg)
MeanderHI = close * (1 + MyAvg + (Deviations * StDev))
MeanderLO = close * (1 + MyAvg - (Deviations * StDev))
RETURN Middle AS "MeanderMiddle",MeanderHI AS "MeanderHigh",MeanderLO AS "MeanderLow"
if you do not import the attached .ITF file, but prefer Copying & Pasting the code into ProBuilder v11, make sure lines 7-8 are uncommented.
Thanks for the update, that definitely shortened the original code! well done.