Had some time to digest... Is this close?
BarPeriod = 240;
int HalfLength = 56;
double BandsDeviations = 2.5;
double FullLength = 2.0*HalfLength+1.0;
vars Price = series(price());
vars Trimavar = series(Trima(Price,5));
var upper = Trimavar[0]+BandsDeviations*sqrt(((FullLength-1)/FullLength)*pow(SMA(Price,1)-Trimavar[0],2));
var lower = Trimavar[0]-BandsDeviations*sqrt(((FullLength-1)/FullLength)*pow(SMA(Price,1)-Trimavar[0],2));
plot("Trimavar1",Trimavar[0],0,GREEN);
plot("upper1",upper,BAND1,RED);
plot("lower1",lower,BAND2,RED);
Key questions:
-How to calculate the upper and lower bands from the Trima. Right now I am not so sure I have it.
-What to use in the Trima Period variable, the MT4 doesn't look at the period in the calculation.
-While i believe that the previous C code could compile with a few changes, I think it doesn't translate well due to the array handling differences between the platforms. Prefer to stick to series.
-Does the Trima function actually emulate the MT4 code. Looking at the source code, i'm not so sure.
Asking these questions has been a learning process, sometimes asking the right question is the hard part!