The Rubric Pattern Predictor defines patterns by comparing the levels of input features, evaluates candidate patterns over a trailing modeling period and uses the patterns that have been historically successful walking-forward. The pattern building phase is repeated every n bars. Inspiration for the Rubric Pattern Predictor came from the Adaptrade Price Pattern Strategies and Price Action Lab.

The initial version does a random search for historically profitable patterns. The reason for the random search is that I wanted to get all of the components into place and see if it looked promising before implementing other search algorithms. The model that I’m going to show you is completely unoptimized in the sense that I’ve made no attempt to find inputs that produce superior results. Under the hood, the Rubric Pattern Predictor does a huge amount of optimization walking-forward. As with all of the Predictors that I’ve built, you never see the hypothetical results over the modeling period.

The Rubric Pattern Predictor is an add-in for Dakota 3 written in C#. The grunt work is run in parallel on the available computer system cores. Currently it can only utilize the CPU’s on 1 computer. Something like this would benefit from distributed processing.

SP non-adjusted daily futures data is loaded from 1/2/1983.

The system is configured to trade on the close of the market on the trading day following the day the system was updated. No trading costs have been applied.

The inputs are the day’s open, high, low, close and a 5, 10 and 20 period simple moving average of the close. The target is the final variable listed on the Dakota 3 Indicators tab and is the ReturnsIndex of the close. Note that the inputs begin after the traded securities open, high, low and close. That’s why the open, high, low and close appear twice in the list of variables.

In the next screen image you will see that the Max Input Depth is set to 5. We are using the most recent 5 rows of inputs to build our feature set. In total there will be 5 x 7 = 35 features available to the algorithm for building patterns.

A pattern condition compares 2 features using the > operator. I’ve setup the Rubric Pattern Predictor so that that it can make use of other operators, but I’m only using the greater than operator for this version. An example pattern condition is:

Close[0] > SMA(Close, 5)[2]

The example condition is requiring the latest closing price to be greater than the simple moving average of the close 2 rows back. Rubric patterns consist of 1 or more conditions. The pattern occurs when all conditions have been met.

The Rubric Pattern Predictor will be available as part of the ATS Pattern Predictor Signal Generators for Dakota 3. Formerly named the KNN Predictors and CPredictor in Dakota 2.

In the image below you can see that we only have 1 bot in the swarm and we’re not making use of swarm adaptation. This system took about 4 hours to walk-forward. Running 15 bots would make sense because it would increase diversity. However, that would require 15 times the processing time. When I build a production model based on the Rubric Pattern Predictor I will be using 15 bots. It would take between 2 and 3 days to walk a system of 15 bots forward on a dual core processor running at 3Ghz.

In the next screen image we can see most of the settings for the Rubric Pattern Predictor.

An explanation of each setting follows.

**Modeling Period**: The Modeling Period defines the number of feature sets used by the Rubric Pattern Predictor for pattern matching. The modeling period trails the bar that is currently being processed. It does not immediately trail the current bar because data is needed for the Max Trade Period, Trading Delay and potentially for the detrending of the target variable.

**Max Input Depth**: The number of input rows that are used to form the set of features for pattern building.

**Min Conditions**: The minimum number of conditions used to form a pattern.

**Max Conditions**: The maximum number of conditions used to form a pattern.

**Min Instances**: The minimum number of times a candidate pattern must have occurred during the modeling period to be considered for use.

**Max Instances**: The maximum number of times a candidate pattern has occurred during the modeling period. If there were more pattern instances than the Max Instances then the pattern is not considered for use.

The Min Gain, Max Loss, Min Win Rate, Min Profit Factor and Max Trade Period are used when evaluating the performance of a given pattern over the modeling period. Hypothetical profits and losses are computed using the detrended target series if the Detrend Period is greater than 1, otherwise they are computed using the target series. Note that the detrended target series will have a smaller variance than the target series. The Dakota 3 trading delay (Project signal by) and selected traded series (Open or Close) apply to keep it as realistic as possible.

**Min Gain**: Hypothetical trades, for a given instance of a pattern, are closed if the gain in equity reaches or exceeds the Min Gain.

**Max Loss**: Hypothetical trades, for a given instance of a pattern, are closed if the equity loss exceeds the Max Loss.

**Min Win Rate**: When evaluating a pattern over the modeling period the hypothetical number of winners divided by the number of trades must be greater than or equal to the Min Win Rate for the pattern to be considered for use.

**Min Profit Factor**: When evaluating a pattern over the modeling period the hypothetical sum of the profitable trades divided by the absolute value of the sum of losing trades must be greater than or equal to the Min Profit Factor for the pattern to be considered for use.

**Max Trade Period**: The maximum period that a hypothetical trade can be open for. The Max Trade Period also applies when walking-forward generating actual trade signals.

**Detrend Period**: The period of the centered simple moving average that is used to detrend the target series. Future versions will probably use a better quality digital filter or at least offer a better quality digital filter as an alternative.

**Evaluation Algo**: Two methods of evaluating candidate patterns over the modeling period are available. The first considers the hypothetical performance of each pattern instances only and the second also examines the average of the equity curves following each instance of a given pattern.

The remaining parameters for the Rubric Pattern Predictor appear in the image below.

**Exit Rule**: System trades can be closed based on a profit target, projected profit or projected duration. The Exit Rule does not apply when evaluating pattern instances, it only applies to actual system trading signals walking-forward. If trades are exited using a profit target then the profit will be computed using the target series.

**Profit Target**: The profit target to use if system trades are closed using the Profit Target method. The profit will be in units of the target series that is the final series defined on the Dakota 3 Indicators tab. The trading delay applies.

**Stop-Loss**: If apply stop-loss is set to True then system trades will be closed if the trade loss exceeds the user specified Stop-Loss amount. The profit is computed using the target series. The trading delay applies.

**Extend Trades**: If Extend Trades is set to True then new patterns can potentially extend the duration of the current trading position.

**Iterations**: The number of patterns to create and evaluate during the pattern building phase.

**Retrain Period**: The number of bars to walk-forward before building a new set of patterns.

**Randomize Retrain**: If Randomize Retrain is set to True then the Retrain Period will randomly vary between 0.75 and 1.25 times the Retrain Period.

The equity curve appears in the image below.

It takes just over 8 years of data before the first trading signal can be generated. The entire equity curve is out-of-sample. It’s not brilliant, however, it’s very promising and it’s early days. I did another run of this system and a very similar shaped equity curve was produced. Tonight I plan to run 10,000,000 iterations to see if results improve or not. The trade statistics follow.

Note that the % Time in Position is greater than 73.55% due to the 8 year period when no signals are output. The next step will be to try using genetic programming to, hopefully, produce superior results faster.

Kind Regards,

James

Hi Andre,

I’ll contact you via email.

Kind Regards,

James