wabbit:As for the moving averages, the short answer is you cannot replace an Undefined() data array with another array. The IsDefined() and IsUndefined() functions were poorly implemented and are next to useless. The only solution is to write another MS add-in that will accept two arguments, returning one array if the other is undefined. I have one for personal use.
As much as the logic you used it is correct, you have still been Kyboshed by the implementaton of the functions in MS.
You (like all of us) might think that
If(IsUndefined(someDataArray)=False, thenUseSomeOtherDataArray, elseUseTheOriginalDataArray)
or
If(isDefined(someDataArray)=True,thenUseTheDataArray,elseUseAnotherDataArray)
would work, but, it doesn't.
Beacuse all the functions in MS are FULLY evaluated, MS sees a function which returns NA and therefore returns NA for that variable.
There is no way around it in MS as it stands at the moment, you need to do the defined/undefined comparison externally and return the appropriate data array from outside of MS. This requires an add-in .dll file.
wabbit
MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
For custom MetaStock programming : http://www.wabbit.com.au
My SkyPE status : 
My SkyPE account : wabbit.com.au