Hello,
I have a portfolio that is 50% market timing.
Does anyone have any tip how I can code the following:
Buy SPY when the month end closing price is above SMA50, and sell when month end closing is below SMA50.
Eg.
Starting cash is $20k, that means $10k is allocated to market timing.
Jan 2010, I purchase 100x SPY at $100k each.
Feb 2010, I sell 100x SPY at $110k each.
Apr 2010, I purchase 122 x SPY at $90 each.
The part I am having problem is to record the total cash I get from selling the SPY, and this amount of cash will be used to purchase SPY when the price is above SMA50.
Does anyone here have any clue how to do this?
Thank you in advanced.