Here is my code for Andreas Clenow's "Stocks on the Move". Using EOD Norgate data.
To recap: its a longonly momentum rotational system, using exponential regression (exponential lineofbestfit) to rank stocks. With a market filter (no new positions taken when SPX below 200 MA).
This is my first coded strategy. Comments or suggestions for improvement are appreciated.
I leave out a few things that Clenow had. No risk parity sizing, just 25 equal weight positions. I trade every day. And I don't exclude gaps.
Some points for discussion below. Most of the talk in this forum is abt code. I don't find any place for discussing strategies or trading  am I in the right place?
#include_once "Formulas\Norgate Data\Norgate Data Functions.afl"
// ***********************************************************************************
// Rorational ranking system. Using Clenow's ranking.
// ***********************************************************************************
// ***********************************************************************************
// 1) Check if stock in index.
// ***********************************************************************************
stockInIdnex = NorgateIndexConstituentTimeSeries("$SPX");
// ***********************************************************************************
// 2) Market Filter Condition
// ***********************************************************************************
FilterIndex = Foreign("$SPX", "Close", 1);
FilterIndexMA = MA( FilterIndex, 200);
inBearMkt = FilterIndex < FilterIndexMA;
// ***********************************************************************************
// 3) Custom Backtest Object to ignore new buys when market filter is false.
// Based on http://www.amibroker.com/kb/2014/10/23/howtoexcludetoprankedsymbolsinrotationalbacktest/
// ***********************************************************************************
SetCustomBacktestProc("");
if ( Status( "action" ) == actionPortfolio )
{
bo = GetBacktesterObject();
bo.PreProcess();
for ( bar = 0; bar < BarCount; bar++ )
{
for ( sig = bo.GetFirstSignal( bar ); sig; sig = bo.GetNextSignal( bar ) )
{
if (inBearMkt[bar])
sig.Price = 1; // exclude
}
bo.ProcessTradeSignals( bar );
}
bo.PostProcess();
}
// ***********************************************************************************
// 6) Clenow score. Find the exponential lineofbestfit.
// Multiply the expected annual increase by Rsquared.
// ***********************************************************************************
colD = log10(Close ); // the log of the close
colE = LinRegSlope( colD, 90 ); // this gives the slope of the regression line
// and we've manipulated it from dollars/day to average percentage move/day
ModelledDailyPercentIncrease = ( ( 10 ^ colE ) ) 1;
ModelledAnnualPercentIncrease = (( (ModelledDailyPercentIncrease +1 ) ^ 250 )); // eg: 12 means 12%
// we took the log so now reverse that.
colG = ( Correlation( Cum( 1 ), colD, 90 ) ^ 2 ); // 90 day RSquared value
ClenowValue = ModelledAnnualPercentIncrease * colG;
// ***********************************************************************************
// 7) Sell when stock is delisted (https://norgatedata.com/amibrokerfaq.php#exitpriortodelisting).
// I had to modify the code to use DateTimeAdd().
// ***********************************************************************************
OnLastTwoBarsOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() >= (LastValue(BarIndex())) OR DateTimeAdd( DateTime(), 2, inDaily) >= GetFnData("DelistingDate") );
// ***********************************************************************************
// 8) Stock Filter Condition
// ***********************************************************************************
stockDisqualified = Close < MA(Close, 100);
SetBacktestMode( backtestRotational );
// ***********************************************************************************
// 9) Position sizing and Trade Entry. 25 positions, 4% each
// ***********************************************************************************
SetOption("MaxOpenPositions",25);
SetOption("WorstRankHeld",800);
SetOption("InitialEquity",100000);
SetPositionSize( 4, spsPercentOfEquity );
SetOption("AllowPositionShrinking", True);
// Configure Trade Entry.
// Can't do it here.
// The rotational trading mode uses "buy price" and "buy delay" from the Settings  Trade page as trade price and delay for both entries and exits (long and short)
/*
BuyPrice = Open;
SellPrice = Open;
SetTradeDelays(1,1,1,1); // Buy/Sell on the next day.
*/
// For exploration
Filter = stockInIdnex;
AddColumn( Close, "Close" );
AddColumn( ClenowValue, "ClenowValue" );
AddColumn( BuyPrice, "BuyPrice" );
// ***********************************************************************************
// Assign final score
// ***********************************************************************************
PositionScore = ClenowValue;
// If stock is disqualified from trading (eg: delisted, not in index, below MA),
// then force its Positionscore to be zero.
PositionScore = IIf(stockDisqualified, 0, PositionScore);
PositionScore = IIf(NOT stockInIdnex, 0, PositionScore);
PositionScore = IIf(OnLastTwoBarsOfDelistedSecurity, 0, PositionScore);
Discussion.

Results
Good returns but large drawdowns. From 1999 to Aug 2018:
 For S&P 500: annual return of 14%, maxDD of 32.5%
 For Russel 3000, annual return of 17.7%, maxDD 32.5%
The drawdowns come after the peaks, where it typically gives back 3040% of the total portfolio value.
Not an easy system to follow.
I don't have 1987 data, but expect it would perform terribly.

Tweaks and Improvements
a) I think it selects better stocks  ie: nicer looking charts  if we put more emphasis on Rsquared. eg: by multiplying by this value twice.
In other words: select more for stocks going up smoothly, rather than just going up.
This increases annual returns into the 20s, and drawdowns into the 40s.
b) Let both winners and losers run further by changing the stock filter condition from MA 100 to Bollinger Bands 100 (1 std dev). This further increases returns and drawdowns.

Clenow's ranking looks at different factors derived from stock prices:
 Momentum (Rate of change, or RoC)
 Acceleration (RoC of RoC)
 Volatility (picks lower volatility by using Rsquared)
It does not look at:
 price/vol action
 support & resistance
Would be interesting to see if these other factors can separately (....and independently) predict momentum.

Would I trade this now (Oct 2018) ?
Maybe, with a small amount. The current bull market may have a few years left.
But after 9 years, we are closer to the end than the beginning.
After the bull market ends and its safer to wade back in, I can always add more money.
Is there anyone else out there that trades trend following or momentum systems?