This set of scripts is a test of the Directional Movement, developed by Wilder, as explained in "The Encyclopedia of Technical Market Indicators" by Colby and Meyers.
According to Wilder, this system identifies a 'trend'- which he claims occurs only 30% of the time. The 2 scripts, DIR_BUY.TAS and DIR_SEL.TAS, test for that trend. For a buy: ADX must be greater than 15 and rising - i have set the criteria that ADX > ADX[-1] > ADX[-2] must be true. Also, PDI must be above MDI - both these conditions must be true for a buy signal. For a sell signal: ADX must be greater than 15 and either ADX is falling - I tested for that as
ADX < ADX[-1] <ADX[-2]; or MDI is above PDI.
For the other 70% of the time that a trend is not in force, other indicators must be used - my preference is Stochastics. STOC_PIC.TAS identifies those tickers where ADX is less than 15 and places them into the ticker file ADX.TCK.
STOC_BUY.TAS and STOC_SEL.TAS then access the ADX.TCK file and perform a stochastic test. The stochastic I used was 14,4 with a 5 day exponential moving average. The buy signal is given if the stoch is greater than 20 and the moving average is less than the stoch and the previous day's stoch was less than 20 and its moving average was greter than the stoch. The sell signal is given is the stoch is less than 80 and its moving average is greater than the stoch and the previous day's stoch was greater than 80 and its moving average was less than the stoch.
I run these from a batch file - PROCESS.BAT. You will notice in the batch file that ADX.TCK is deleted before STOC_PIC.TAS is run, so that there will be no overlap of ticker symbols in the file.
I hope you find these scripts useful, and would appreciate any comments or constructive hints.