I want to create a 'rank' factor based on the monthly increases in Moving Averages over a year, such that the more recent Moving Average get more weight over the older ones. So points are given for each month the Moving Average was higher than the previous month's Moving Average, with the more recent Moving Averages giving more points.

This is the (incorrect) formula. Please correct it for me!

```
MA11MonthBack = MA(ref(C, 30),330);
MA10MonthBack = MA(ref(C, 30),300);
MA09MonthBack = MA(ref(C, 30),270);
MA08MonthBack = MA(ref(C, 30),240);
MA07MonthBack = MA(ref(C, 30),210);
MA06MonthBack = MA(ref(C, 30),180);
MA05MonthBack = MA(ref(C, 30),150);
MA04MonthBack = MA(ref(C, 30),120);
MA03MonthBack = MA(ref(C, 30),90);
MA02MonthBack = MA(ref(C, 30),60);
MA01MonthBack = MA(ref(C, 30),30);
MA00MonthBack = MA(C,30);
rank = 0;
if (MA00MonthBack > MA01MonthBack) rank = rank + 18;
if (MA01MonthBack > MA02MonthBack) rank = rank + 16;
if (MA02MonthBack > MA03MonthBack) rank = rank + 14;
if (MA03MonthBack > MA04MonthBack) rank = rank + 12;
if (MA04MonthBack > MA05MonthBack) rank = rank + 10;
if (MA05MonthBack > MA06MonthBack) rank = rank + 08;
if (MA06MonthBack > MA07MonthBack) rank = rank + 07;
if (MA07MonthBack > MA08MonthBack) rank = rank + 06;
if (MA08MonthBack > MA09MonthBack) rank = rank + 05;
if (MA09MonthBack > MA10MonthBack) rank = rank + 04;
if (MA010MonthBack > MA11MonthBack) rank = rank + 03;
```