Dear Community,
I am chasing an error in rotational trading. Using backtest and exploration I have narrowed down the situation.
- a watchlist with 7 symbols from Norgate: AABA-201910, AEO, AMZN, BVSN-202005, MFNXQ-200209, NSOL-200006, STCN. Filter applied to this watchlist.
- a piece of code, modified from the published ExampleRotational.afl
MaxPositions = 3;
SetOption("MaxOpenPositions", MaxPositions );
SetOption("WorstRankHeld", MaxPositions );
SetPositionSize( 100 / MaxPositions, spsPercentOfEquity );
SetTradeDelays( 1, 1, 1, 1 );
BuyPrice = Open;
SetBacktestMode( backtestRotational );
change = ROC( Close, 10 );
PositionScore = 10000 + change;
if( Status( "action" ) == actionExplore )
{
Filter = 1;
AddColumn( Close, "Close ", 6.2 );
AddColumn( PositionScore, "PositionScore", 6.2 );
}
- Setting is monthly, range 01.07.1998-01.08.1998. Trade next bar on open (also in the code). Align to $NDX.
Explore gives me this list, sorted by PositionScore:
Ticker,Date/Time,Close ,PositionScore
STCN,31.07.1998,73.34,10453.30
AMZN,31.07.1998,0.92,10325.93
AEO,31.07.1998,4.97,10300.34
AABA-201910,31.07.1998,3.10,10262.97
BVSN-202005,31.07.1998,478.90,10192.07
NSOL-200006,31.07.1998,9.00,
MFNXQ-200209,31.07.1998,3.51,
Backtest gives me this list (columns deleted after ex.price):
Symbol,Trade,Date,Price,Ex. date,Ex. Price,
AMZN,Open Long,31.07.1998,0.8484375,31.07.1998,0.9239584,
STCN,Open Long,31.07.1998,79.39613,31.07.1998,73.3405,
BVSN-202005,Open Long,31.07.1998,611.8776,31.07.1998,478.9042,
I have two strange findings:
-
BVSN is on backtest 3rd rank. From PositionScore I would expect BVSN on 5th rank, and instead AEO on the 3rd rank.
-
the prices in backtest are not the opening prices of the next period (01.08.1998) but the opening prices of the past period (01.07.1998). This contradicts the delay setting.
Is there an error in my code? Or do I have a big misunderstanding in the application of the system?
thanks
Andreas