@seaworthy It is probably worth checking with @NorgateData Richard Dale to see if the following code is correct. But I too have the NDU data feed and have put together this small afl to check for accurate prices and historically correct Index constituents.
I’ve used my own selected numbers for minimum Stock Price and volume for filters but obviously depending on your system or what you are trading you should insert your own preferred prices and volumes as filters.
I have run a couple of backtests and this seems to work but no promises as to it’s accuracy. If you check it too and it works it would be great to hear about it.
//// Liquidity and NDU historically accurate constituent filter ////
// v1.1 added the line for IndexSymbol and then used
// IndexSymbol in place of "....index name or symbol"
#include_once "Formulas\Norgate Data\Norgate Data Functions.afl"
IndexSymbol = "$NDX"; // here is only place where you enter the Index symbol you want to test
// Norgate symbols
// $RUA is Russell 3000, $RUI is Russell 1000, $RUT is Russell 2000
// $SPX is SP500, $SP1500 is SP1500, $MID is SP400 MidCap,
// $NDX is Nasdaq 100 $DJI is Dow Jones Industrial Average
oc = NorgateOriginalCloseTimeSeries(); // NDU datafeed function for original unadjusted Closing price
ov = NorgateOriginalVolumeTimeSeries(); // NDU datafeed function for original unadjusted Volume
MinimumPriceFilter = Ref( oc, -1 ) > 2; // yesterday's Original Close > $2.00
minVolume = Ref( ov, -1 ) > 100000; // yesterday's Original Volume > 100,000 shares
Turnover = ( oc * ov ); // you could choose to set a minimum for the day before the trade here too
MinimumAvgTurnover = MA( Turnover, 10 ) > 1500000; // $1,500,0000 average turnover past 10 days
// NORGATE instructions for dealing with delisted securities
// Do not enter if on last two bars of an inactive security, these two lines are from Norgate
OnSecondLastBarOfDelistedSecurity = !IsNull( GetFnData( "DelistingDate" ) ) AND( BarIndex() == ( LastValue( BarIndex() ) - 1 ) OR DateTime() >= GetFnData( "DelistingDate" ) ) ;
OnLastTwoBarsOfDelistedSecurity = !IsNull( GetFnData( "DelistingDate" ) ) AND( BarIndex() >= ( LastValue( BarIndex() ) - 1 ) OR DateTime() >= GetFnData( "DelistingDate" ) );
Liquid = MinimumPriceFilter
AND NorgateIndexConstituentTimeSeries( IndexSymbol ) // use appropriate Index symbol for system/Index you are testing on
AND NOT OnLastTwoBarsOfDelistedSecurity;
ENTER YOUR ENTRY AND EXIT RULES BELOW
Buy = Buy AND Liquid;
Sell = Sell OR OnSecondLastBarOfDelistedSecurity;
// If you have a short selling system you will also need to include the following:
Short = Short AND Liquid;
Cover = Cover OR OnSecondLastBarOfDelistedSecurity;