I am writing a dollar cost averaging formula using this:
MonthBegin = Month() != Ref( Month(), -1 );
PositionSize = 200; // $200 per month
Buy = IIf( MonthBegin, sigScaleIn, 0 );
I would like to amend this so that if C<MA(20) on the monthbegin, store that month's $200 in cash - and then when the C>MA(20) on monthbegin, buy all the missed months of cash:
Jan-March : C<MA20 - so this is 3x$200 = $600 stored as cash, not in shares
April 1st C>MA20: so buy the $200 for this month + $600 stored in cash = $800 purchase
May 1st C>MA20: just buy $200
etc...
Buy = IIf( MonthBegin, IIf(C>MA(C,20), sigScaleIn {{{AND BUY NUMBER OF MISSED MONTHS}}}, {{{STORE IN CASH}}}), 0 );
Thank you as always