I am doing a rotational backtest to hold the 10 highest momentum stocks in the S&P 500 using Norgate's historical approach. It all appears to work well, but all trades are exited immediately. Here is a portion of the report:
And there is the script:
// Load the Norgate tools
#include_once "Formulas\Norgate Data\Norgate Data Functions.afl"
// invoke the rotational tester
SetBacktestMode(backtestRotational);
// number of positions to hold
MaxPositions = 10;
SetOption("MaxOpenPositions", MaxPositions );
// cutoff rank
SetOption("WorstRankHeld", 10);
// set position size to leave approximately 5% cash
SetPositionSize( 100 / MaxPositions, spsPercentOfEquity);
SetOption("AllowPositionShrinking", True);
// trade at the open
SetTradeDelays(1, 1, 1, 1);
BuyPrice = Open;
// one year using weekly data
LookBack = 52;
// add large integer to prevent short positions
PositionScore = IIf(NorgateIndexConstituentTimeSeries("$SPX"), 10000 + ROC( C, LookBack), 0);
// That's all folks!
Thanks for the reply! That was one of the first debugging steps I took. The components of the S&P 500 (current and lapsed) return non-zero position scores. However the equities not in the S&P returned zero scores. So I changed the PositionScore line to:
PositionScore = IIf(NorgateIndexConstituentTimeSeries("$SPX"), 10000 + ROC( C, LookBack), 900);
That eliminates the zeros, but I still get the early exits. (I have stops turned off.)