When Optimization is Really Slow

Generally, optimization in the NeuroShell Trader Professional or DayTrader Professional is pretty fast. However, there is one generic situation in which optimization can be very, very slow. That situation is whenever your trading strategy in some way uses an indicator having the parameter “Trading Strategy”, and that parameter is set to the same trading strategy you are building. This “recursive” use of the trading strategy causes an exponential increase in the number of calculations required during optimization, increasing with the number of trades the strategy makes.

The most common example of this is when you insert a trailing stop which uses an indicator like those found in the category “Trading Strategy: Protective Stops”. Another common situation is when you have an entry or exit rule using an indicator in the category “Trading Strategy: Position Information”.

In some cases, like whenever there are hundreds of trades, or you are using that indicator within other indicators, the slow-down can be on the order of hundreds of times slower!

So what to do? If you don’t mind the time it takes, you don’t have to do anything.

If the time is excessive for what you are doing, then try using an indicator that doesn’t have the “Trading Strategy” parameter. For example, if making a trailing stop, build an indicator that bases the stop off of the close, e.g., close plus or minus X. If that’s impractical, consider using the indicators in Trading Strategy: Exit Signals, which are a lot faster than their counterparts. For example, instead of using “Bars since entry activated” with the A=B relational, use “Bars since activated=x”. The latter is much much faster.

You might also want to try max high or low over last n bars, plus or minus x, which more closely approximates the ‘Trailing Price: Percent’ and ‘Trailing Price: Point’ indicators.

Another thing to try is reducing the number of bars being optimized, which will speed things up because you generally will have less trades in a smaller data set. Of course, the danger here is overfitting.

A final thing you can do is try to build and optimize a neural net or trading strategy that works pretty well without trailing stops. Then just add the trailing stops as a transaction between you and your broker. After all, trailing stops are just insurance, and it can be argued that the insurance shouldn’t be optimized anyway! Optimize the strategy, and then just add on the insurance. (You can simulate this in the Trader Pro, but it probably will not give the same results as just doing stops with your broker, because if any stops are taken in the backtest, the model may get back in at a different point than it would have, which then may throw off the whole sequence. To simulate, first optimize the model. If the strategy is a reversal one, check the box marked “Long/Short entries exit short/long positions”. Then add in the stops, but when NeuroShell asks if you want to continue optimizing using the last optimal settings as a starting point, press cancel. The backtest goes forward without optimization but with the new stops.)

In the end if you don’t feel you can use the alternatives above, just go ahead and use the stops. You can stop optimization early as soon as you see results you like. You can also set the number of minutes you want optimization to run (i.e., you don’t have to use our default time for optimization). Also, you don’t have to OPTIMIZE the stops at all. Most people know what their pain threshold is, and they don’t need an optimizer to tell them that. To keep the stops from optimizing, just set the ranges of the parameters in the stops so that the min=the max. The ranges can be viewed by clicking on the + sign to the left of an indicator or rule.

Another reason optimization can be slow is if you are using one of our addons, like Adaptive Turboprop 2, and loading it up with inputs or hidden neurons. The addons are far more computationally intense than the normal indicators are.

For example, suppose you are using Adaptive Turboprop 2 with a training set size of 1000 bars, and you are retraining every bar. Your optimal set contains 10000 bars. This means that EVERY individual in the genetic population has to have 9000 neural nets trained for it on every generation, each with a training set of 1000 bars. Especially if you are using more than a couple of hidden neurons, that can take quite a while, even with our fast nets!

Many of our users like to build a hierarchy of addons. They’ll feed Adaptive Turboprop 2 nets into cluster indicators, etc. That’s ok, but it produces a whole lot of variables that need to be optimized, not to mention the additional computational intensity.

Bottom line: genetic algorithms can take on a whole lot of work, but please don’t expect today’s computers to be able to keep up with everything the NeuroShell Trader Professional can throw at them!

Was this article helpful?

Related Articles