Hi All,
Many apologies if this has already been addressed in another post by someone. I have done a search on the forum and on google and can find similar threads, but nothing directly addressing my issue.
I have a monthly momentum rotational system that I have written, and I would like to benchmark it to the SPY. The issue is that because the system will exit any stocks falling out of the top ranked list monthly and then enter any stocks that have newly entered it (entering a constant position size each time), comparing it to a buy and hold strategy of the SPY would be like comparing apples and oranges, since one is basically compounding and the other is not.
To try and get a more green apples to red apples comparison, I had just thought to write a code that would enter at the open of the 1st day of the month (say $100K position in SPY), exit that position at the open of the first day of the next month, then immediately re-enter (with $100K position size again). My issue is that when I wrote a simple code to do this:
/********* ROTATIONAL DAY CHECK *********/
RotationDay = 1;
BarDay = Day();
BarMonth = Month();
IsRotationDay = 0;
for ( i = 0; i < BarCount; i++ )//begin iterating through the bars
{
if ( i-1 >= 0 AND i < BarCount)
{ //to avoid access array elements outside of 0 to Barcount-1
if ( BarDay[i] >= RotationDay AND ( BarDay[i-1] < RotationDay OR BarMonth[i-1] != BarMonth[i] ) OR ( BarMonth[i-1] != BarMonth[i] AND BarDay[i-1] < RotationDay ) )
{
IsRotationDay[i] = 1;
}
}
}
Buy = Sell = IsRotationDay;
Cover = Short = 0;
I find that the backtester enters then immediately exits the trade for 0 profit/loss for 0 time. In effect, at the start of each month, I want to sell, then buy, then wait a month, then repeat. But this code buys, then sells, then waits one month. I would like to get it to sell first then buy, not buy first then sell. I cannot set a buy delay since I am using end of day data and delaying the buy for an entire delay won't give the same results. Is there a simple way to do this I am missing without going into the CBT.
Or if I have to go into the CBT, does anyone know of a link to a code I could use as a template, that will do something similar?
I'm also open to ideas about how to make a better apples to apples comparison than this. Because the rotational strategy will only rebalance part of the portfolio each month (the stocks that newly enter), held stocks will compound, it isn't a straight apples to apples comparison either. The only thing I can think of here, would be to exit every single position at the start of the month and re-enter all at the say $10K (for 10 positions, makes .the same $100K float to compare with SPY example).
Anyway, thank you all for viewing and for any advice.
Cheers,
W.