Wabbit,
Here is the code and an explaination....hope it's clear.
The formula plots a 9 day "Centered Avg", and plots a "Derived Avg" + a correction factor "Dif" during the 4 day blank 1/2 cycle delay period. The formula uses a nest of 5 "IFs" and works. "Dif" is calculated on day 5 (RBC=5), the last day the "Centered Avg" is plotted. The remaining 4 days are calculated by the 2nd, 3rd, 4th, and 5th "IFs" and use the "Dif" calculated on day 5.
The 1st "IF" plots the Centered Avg
The 2nd "IF' plots the Derived Avg + Dif on day RBC=4
The 3rd "IF" plots the Derived Avg+ Dif on day RBC=3
The 4th "IF" plots the Derived Avg + Dif on day RBC=2
The 5th "IF" plots the Derived Avg + Dif on day RBC=1
The problem is, coding a 31 Day Avg ends up overloading the compiler.
CenteredAvg:= Fml( "+ag Avg 9");
DerivedAvg:= Fml( "+ag Derived Avg 9");
Dif:=CenteredAvg-DerivedAvg;
Defineda:= IsDefined(CenteredAvg);
CenteredAvg:= ExtFml( "Forum20.Sum",CenteredAvg,1);
RBC:= LastValue(Cum(1))-Cum(1)+1;
If(Defineda,CenteredAvg,
If( IsDefined(If(rbc=4,Ref(dif,-1),0)),
DerivedAvg +ExtFml( "Forum20.Sum",If(rbc=4,Ref(dif,-1),0),1),
If(IsDefined(If(rbc=3,Ref(dif,-2),0)),
DerivedAvg +ExtFml( "Forum20.Sum",If(rbc=3,Ref(dif,-2),0),1),
If(IsDefined(If(rbc=2,Ref(dif,-3),0)),
DerivedAvg +ExtFml( "Forum20.Sum",If(rbc=2,Ref(dif,-3),0),1),
If(IsDefined(If(rbc=1,Ref(dif,-4),0);),
DerivedAvg +ExtFml( "Forum20.Sum",If(rbc=1,Ref(dif,-4),0);,1),
L)))));