Original LUA indicator: http://fxcodebase.com/code/viewtopic.php?f=17&t=24476.
Formulas:
CMA[i] = SMA[i+Length/2] for all bars except the last Length/2 bars,
CMA[i] = (Sum of the prices(from (i-Length/2) to last bar)+(Last bar price)*(Length/2-i-1))/Length.
Download: