See the note at the bottom of this reply
The formula that is using the index() function isn't going to work for a weighted calculation. What I assume you want to do is illustrated by the following formula
Mean(
Lag( ::Mean1, 1 ) * 1,
Lag( ::Mean1, 1 ) * 4,
Lag( ::Mean1, 1 ) * 6,
Lag( ::Mean1, 1 ) * 4,
Lag( ::Mean1, 1 ) * 1
);
This structure doesn't allow the simple 2 level calculation, so it has to be expanded, but is is basically the same logic
If( :sample != Lag( :sample, 1 ) | Row() == 1,
counter = 0;
);
counter = counter + 1;
If( counter == 1,
:Mean1,
counter ==2,
Mean(
Lag( ::Mean1, 1 ) * 1,
Lag( ::Mean1, 1 ) * 4
),
counter ==3,
Mean(
Lag( ::Mean1, 1 ) * 1,
Lag( ::Mean1, 1 ) * 4,
Lag( ::Mean1, 1 ) * 6
),
counter ==4,
Mean(
Lag( ::Mean1, 1 ) * 1,
Lag( ::Mean1, 1 ) * 4,
Lag( ::Mean1, 1 ) * 6,
Lag( ::Mean1, 1 ) * 4
),
Mean(
Lag( ::Mean1, 1 ) * 1,
Lag( ::Mean1, 1 ) * 4,
Lag( ::Mean1, 1 ) * 6,
Lag( ::Mean1, 1 ) * 4,
Lag( ::Mean1, 1 ) * 1
)
);
And after all of this, I found the Col Moving Average() function. So don't do anything above that I suggested, instead, go to
Help==>Scripting Index==>Col Moving Average
and you will get a single function that will do everything you have asked for
Jim