Hi everyone,
I'm trying to better understand how Pad and Align works. I have a 1-minute data base, which I populated with many actual quotes for forex symbols, and then I added the following:
- 1 minute fake reference symbol, which has quotes for all trading days, with a granularity of 1 minute. So, I have quotes for 00:00, 00:01, 00:02, ..., 23:59, then for the next trading day 00:00, ... and so on
- daily bars for SP500
I do have "Allow mixed EOD/Intraday data" checked, and had it enabled before importing daily SP500.
Now, given the code below, the backtest produces different behaviors with and without Pad and Align.
I assume AmiBroker assigns a timestamp of 23:59:59 for daily quote, which is a fair choice, because only at the end of the day one would have the Close price, and 23:59:59 is indeed the end of a day.
I would like to have someone confirm that assumption, or explain how else I get the with/without behavior shown in the picture below. With that assumption in place, it's clear that when trading happens at 00:00:00, there is no quote for that day (yet), so the one from the previous day is used.
Here is the code:
SetOption( "FuturesMode" , False );
SetOption( "SettlementDelay" , 0 );
SetOption( "ActivateStopsImmediately", True );
SetOption( "AllowSameBarExit" , True );
SetOption( "ReverseSignalForcesExit", False );
SetOption( "PortfolioReportMode" , 0 );
SetOption( "PriceBoundChecking" , False );
RoundLotSize = 0;
PointValue = 1;
SetOption( "InitialEquity" , 100000);
SetOption( "AccountMargin" , 100 );
SetOption( "MaxOpenPositions" , 200 );
SetOption( "AllowPositionShrinking" , False );
SetOption( "MinShares" , 0.01 );
SetOption( "MinPosValue" , 0.01 );
SetOption( "CommissionMode" , 3 ); // $ per share or contract
SetOption( "CommissionAmount" , 0 ); // $ commission (per side)
SetOption( "InterestRate" , 0 );
SetPositionSize( 1, spsShares );
// very simple test rules
Buy = DayOfWeek() == 1;
Sell = DayOfWeek() == 5;
Short = Cover = 0;
BuyPrice = O;
SellPrice = C;
Thank you!