I was running some AFL strategies which I thought should give the same results whether I ran them on a daily time frame or a monthly time frame because they were always trading at the close of the month.
The open of the first day of the month is identical to the open of the month and the close of the last day of the month is identical to the close of the month. So if you are trading the same symbols at only the open or close of the month you should get the same results on either time frame. And you do sort of but not exactly. I'm wondering why the results are not exactly the same. What follows is a test program that shows the differences in the results.
//--- DayMonth Test
// Open of the first day of the month is identical to the open of the month
// Close of the last day of the month is identical to the close of the month
// A strategy that trades only one of those two times should produce
// identical results whether traded when Periodicity is set to Daily or Monthly
// This program was designed to test the results produced by Amibroker on both.
//=============================================================================
//--- Standard settings not changed
SetBacktestMode(backtestRegular); // Setup for back test type
SetOption("InitialEquity", 100000); // Starting dollar amount
SetOption("AccountMargin", 100); // Cash % traded (100% = no margin, 75% = 25% margin used)
SetTradeDelays(0,0,0,0); // Disable Amibroker trade delays
SetOption("SeparateLongShortRank", True);
SetOption("UsePrevBarEquityForPosSizing", False); // Use current bar equity
SetOption("EveryBarNullCheck", True); // No null bars allowed
SetOption("PriceBoundChecking", True); // Prices constrained to between low and high values
SetOption("MaxOpenPositions", 2); // Only two trades at a time
SetPositionSize(50, spsPercentOfEquity); // Always trade 50% of equity
SetOption("AllowPositionShrinking", True); // Limit trade size based on available funds in account
SetOption("SettlementDelay", 0); // Broker dependent. Proceeds from sale only available for new trades x days after sale
SetOption("MinShares", 1); // Minimum trade size 1 share
SetOption("AllowSameBarExit", True); // Allow entering new trades at same time previous trades are exited
SetOption("ReverseSignalForcesExit", False);
SetOption("FuturesMode", False); // Stock trading mode
//--- Idenditify last day of the month
MonthEnd = TimeFrameExpand(1, inMonthly, expandPoint); // True on only the last day of the month
//--- Calculate a position score to rank symbols for trading
MonthClose = TimeFrameCompress(C, inMonthly, compressLast); // Monthly price no matter what Periodicity is set to
PositionScore = ROC(MonthClose, 3); // Positionscore always based on 3 month ROC
PositionScore = TimeFrameExpand(PositionScore, inMonthly); // Expand score to current time frame
//--- Buy and sell on last day of the month
BuyPrice = SellPrice = C; // Buy and sell on close
Buy = MonthEnd AND PositionScore > 0;
Sell = MonthEnd AND !Buy;
I understand why some of metrics differ like Profit/Bar, MAE, MFE, but not the Profit, % Profit, and Shares. I included a lot of SetOptions to make sure everything was identical except for the time frame.
I run this program over a range of a year or more on sector symbols first on Daily Periodicity and then again on Monthly Periodicity. The symbols, dates, and prices appear to be identical on both time frames and for the first few trades everything else related to trade size appears to match exactly, but as time and the trades progress the trade size and profits drift. They are close, but not exactly the same. And in the end the differences show up in the CAR which is an important metric. I don't understand why. They are trading at the same time on the same symbols and at the same price.
Is there a setting I don't have right or is there something else I'm missing?



