Thanks for reply. I will try to look better at what PerformanceAnalytics has to offer. Anyways, after some long and painful searching and coding (correcting all those tiny details in code is really frustrating) I found that such function actually exits. It does what I want it to do, however, then the backtesting time greatly increases, so I think I will have to stick to osMaxDollar or anything simpler.
By the way, does any one of you know any efficient and convenient ways to evaluate risk management/asset allocation/ position sizing strategies?
Finally I attach my MA crossover rules for anyone else who is looking for a position sizing based on current equity.